http://llvm.org/bugs/show_bug.cgi?id=17713

            Bug ID: 17713
           Summary: missed opportunity to optimize FP division into
                    multiplication
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Using:
$ ./clang -v
clang version 3.4 (trunk 193529) (llvm/trunk 193527)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

Consider the following reduced code example:
$ cat recip.c 
double foo(double x, double y) {
    if (y == 2.0) return x/y;
    return x;
}

$ ./clang -O3 -fomit-frame-pointer  -o - -S recip.c
    .section    __TEXT,__text,regular,pure_instructions
    .section    __TEXT,__literal8,8byte_literals
    .align    3
LCPI0_0:
    .quad    4611686018427387904     ## double 2
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _foo
    .align    4, 0x90
_foo:                                   ## @foo
    .cfi_startproc
## BB#0:                                ## %entry
    ucomisd    LCPI0_0(%rip), %xmm1
    jne    LBB0_2
    jp    LBB0_2
## BB#1:                                ## %if.then
    divsd    %xmm1, %xmm0
LBB0_2:                                 ## %return
    ret


It would be great if clang/llvm recognized that the division operation by an
exactly representable FP constant can be reduced to a multiplication. GCC can
do this optimization.

-- 
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