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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to