https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92578

            Bug ID: 92578
           Summary: [i386] cmov not generated
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
                CC: hjl.tools at gmail dot com
  Target Milestone: ---

Cat test.c

int foo(int moves, int movecnt, int komove) {
    int newcnt = movecnt;
    if (moves == komove)
        newcnt--;
    return newcnt;
}

gcc10 -O2 test.c -S

        cmpl    %edx, %edi
        movl    %esi, %eax
        sete    %dl
        movzbl  %dl, %edx
        subl    %edx, %eax
        ret

It could be better like

        cmpl      %edx, %edi                                    #6.12
        lea       -1(%rsi), %eax                                #5.9
        cmovne    %esi, %eax                                    #6.12
        ret      

Just like icc did, refer to https://godbolt.org/z/6mqkt8

Reply via email to