https://bugs.llvm.org/show_bug.cgi?id=40646

            Bug ID: 40646
           Summary: cmov regression
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: antonin.k...@gmail.com
                CC: llvm-bugs@lists.llvm.org

Created attachment 21443
  --> https://bugs.llvm.org/attachment.cgi?id=21443&action=edit
simple source file

clang has stopped using cmov instruction in the following
case(https://godbolt.org/z/CvPhJo)

clang-trunk: 
offset(ctx&, unsigned long):
        mov     rax, qword ptr [rdi + 8]
        mov     rcx, qword ptr [rdi + 16]
        sub     rax, rcx
        cmp     rax, rsi
        setae   al
        jae     .LBB0_1
        mov     rcx, qword ptr [rdi]
        mov     qword ptr [rdi], rcx
        ret
.LBB0_1:
        add     rcx, rsi
        mov     qword ptr [rdi], rcx
        ret

clang-5:
offset(ctx&, unsigned long):
        mov     rax, qword ptr [rdi + 8]
        mov     rcx, qword ptr [rdi + 16]
        sub     rax, rcx
        add     rcx, rsi
        cmp     rax, rsi
        setae   al
        cmovb   rcx, qword ptr [rdi]
        mov     qword ptr [rdi], rcx
        ret

gcc-trunk:
offset(ctx&, unsigned long):
        mov     rdx, QWORD PTR [rdi+16]
        mov     rcx, QWORD PTR [rdi+8]
        sub     rcx, rdx
        cmp     rsi, rcx
        setbe   al
        add     rdx, rsi
        cmp     rsi, rcx
        cmova   rdx, QWORD PTR [rdi]
        mov     QWORD PTR [rdi], rdx
        ret

Maybe there is a good reason why clang is not using cmov but according to this
measurement https://github.com/xiadz/cmov, cmov seems to be the better choice.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to