Skip to content

cmove is not emitted for a simple expression #90017

@EgorBo

Description

@EgorBo
int foo(bool cond, int a, int b) => 1 + (cond ? a : b); // or e.g. "cond ? 1 : 2"

Current codegen:

; Method Program:foo(bool,int,int):int:this (FullOpts)
       test     dl, dl
       jne      SHORT G_M62184_IG04
       mov      eax, r9d
       jmp      SHORT G_M62184_IG05
G_M62184_IG04:  ;; offset=0x0009
       mov      eax, r8d
G_M62184_IG05:  ;; offset=0x000C
       inc      eax
       ret      
; Total bytes of code: 15

Expected: branchless code (cmove)

cc @jakobbotsch @dotnet/jit-contrib

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions