https://bugs.llvm.org/show_bug.cgi?id=39534
Bug ID: 39534
Summary: suboptimal codegen for conditional float return?
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
bool isNanOrInf(float x)
{
return (reinterpret_cast<unsigned&>(x) & 0x7F800000) == 0x7F800000;
}
float test(float x)
{
return isNanOrInf(x) ? 0 : x;
}
test(float):
vmovd eax, xmm0
not eax
vpxor xmm1, xmm1, xmm1
and eax, 2139095040
je .LBB1_2
vmovdqa xmm1, xmm0
.LBB1_2:
vmovdqa xmm0, xmm1
ret
In contrast gcc does not use xmm1 at all:
test(float):
vmovd eax, xmm0
mov edx, 2139095040
and edx, eax
cmp edx, 2139095040
je .L5
ret
.L5:
vxorps xmm0, xmm0, xmm0
ret
https://gcc.godbolt.org/z/biNBFq
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs