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


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to