Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

ARM64: redundant overflow and divbyzero checks #98100

Closed

Description

@EgorBo
int Test(int a, int b) => b != 0 ? a / b : 0; // or e.g. "b > 0" etc

Current codegen on ARM64:

; Method Prog:Test(int,int):int:this (FullOpts)
G_M26116_IG01:
            stp     fp, lr, [sp, #-0x10]!
            mov     fp, sp
G_M26116_IG02:
            cbnz    w2, G_M26116_IG05
G_M26116_IG03:
            mov     w0, wzr
G_M26116_IG04:
            ldp     fp, lr, [sp], #0x10
            ret     lr
G_M26116_IG05:
            cmp     w2, #0
            beq     G_M26116_IG08
            cmn     w2, #1
            bne     G_M26116_IG06
            cmp     w1, #1
            bvs     G_M26116_IG09
G_M26116_IG06:
            sdiv    w0, w1, w2
G_M26116_IG07:
            ldp     fp, lr, [sp], #0x10
            ret     lr
G_M26116_IG08:
            bl      CORINFO_HELP_THROWDIVZERO
G_M26116_IG09:
            bl      CORINFO_HELP_OVERFLOW
            brk_windows #0
; Total bytes of code: 72

in this case JIT should be able to remove the CORINFO_HELP_THROWDIVZERO since b is proven to be always != 0.

Activity

  1. ghost added
    area-CodeGen-coreclr
    on Feb 7, 2024
  2. ghost added
    untriaged
    on Feb 7, 2024
  3. self-assigned this
    on Feb 7, 2024
  4. removed
    untriaged
    on Feb 7, 2024
  5. added this to the 9.0.0 milestone on Feb 7, 2024
  6. ghost added
    in-pr
    on Feb 7, 2024
  7. ghost removed
    in-pr
    on Feb 9, 2024
  8. locked and limited conversation to collaborators on Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-arm64area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions