[llvm-bugs] [Bug 50991] New: [X86] Failure to flip cmov cc for -abs(x)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 6 02:41:28 PDT 2021


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

            Bug ID: 50991
           Summary: [X86] Failure to flip cmov cc for -abs(x)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

https://godbolt.org/z/frMb5fahz

#include <cmath>

char nabs8(char x) {
    return -std::abs(x);
}

short nabs16(short x) {
    return -std::abs(x);
}

int nabs32(int x) {
    return -std::abs(x);
}

long long nabs64(long long x) {
    return -std::abs(x);
}

clang:

nabs64(long long):
        movq    %rdi, %rax
        negq    %rax
        cmovlq  %rdi, %rax
        negq    %rax
        retq

gcc:
nabs64(long long):
        movq    %rdi, %rax
        negq    %rax
        cmovns  %rdi, %rax
        ret

-- 
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/20210706/16c4976c/attachment.html>


More information about the llvm-bugs mailing list