https://bugs.llvm.org/show_bug.cgi?id=36260
Bug ID: 36260
Summary: Possibly missed optimization (performance and code
size) when comparing floats as raw binary
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: kobalicek.p...@gmail.com
CC: llvm-bugs@lists.llvm.org
The following code
------------------
#include <stdint.h>
#include <xmmintrin.h>
#include <emmintrin.h>
union F64 {
double d;
uint64_t u;
};
uint32_t compareBin(double a, double b) noexcept {
F64 a_ = { a };
F64 b_ = { b };
return a_.u == b_.u;
}
uint32_t compareDbl(double a, double b) noexcept {
return a == b;
}
Compiles to (-O2 -mavx2 -fno-math-errno):
-----------------------------------------
compareBin(double, double): # @compareBin(double, double)
vmovq rcx, xmm0
vmovq rdx, xmm1
xor eax, eax
cmp rcx, rdx
sete al
ret
compareDbl(double, double): # @compareDbl(double, double)
vcmpeqsd xmm0, xmm0, xmm1
vmovq rax, xmm0
and eax, 1
ret
I think the `compareBin` should use the same approach as `compareDbl`, which
would be:
compareBin(double, double):
vpcmpeqq xmm0, xmm0, xmm1
vmovq rax, xmm0
and eax, 1
ret
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs