[LLVMbugs] [Bug 6032] New: Unnecesary branching generated for "x == x ? x : x + x; " floating point expr
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Wed Jan 13 14:35:15 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=6032
Summary: Unnecesary branching generated for "x == x ? x : x +
x;" floating point expr
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Backend: X86
AssignedTo: unassignedbugs at nondot.org
ReportedBy: jan_sjodin at yahoo.com
CC: llvmbugs at cs.uiuc.edu
For the C function
double d1(double x) { return x == x ? x : x + x; }
The LLVM CPU back end is generating branches. E.g. ToT clang produces:
d1:
.Leh_func_begin1:
pushq %rbp
.Llabel1:
movq %rsp, %rbp
.Llabel2:
ucomisd %xmm0, %xmm0
jnp .LBB1_2
addsd %xmm0, %xmm0
.LBB1_2:
popq %rbp
ret
However, it is possible to handle this in a branch free fashion using the CMPSD
instruction to produce a mask which can then be used in simple logical
operations to produce the desired result.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list