[llvm-bugs] [Bug 40646] New: cmov regression

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 7 06:53:07 PST 2019


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: unassignedbugs at nondot.org
          Reporter: Antonin.kriz at gmail.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190207/e5855cb3/attachment.html>


More information about the llvm-bugs mailing list