[LLVMbugs] [Bug 17713] New: missed opportunity to optimize FP division into multiplication

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 28 14:28:36 PDT 2013


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: unassignedbugs at nondot.org
          Reporter: kkhoo at perfwizard.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131028/c0a2e91d/attachment.html>


More information about the llvm-bugs mailing list