[LLVMbugs] [Bug 21962] New: FP constants not combined (fast-math)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Dec 18 08:59:01 PST 2014


            Bug ID: 21962
           Summary: FP constants not combined (fast-math)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat fadd.c
double foo(double x, double y) {
    return -( x + 1.0 + y + 2.0 );

Or as IR:
define double @foo(double %x, double %y) {
  %add = fadd fast double %x, 1.000000e+00
  %add1 = fadd fast double %add, %y
  %add2 = fadd fast double %add1, 2.000000e+00
  %sub = fsub fast double -0.000000e+00, %add2
  ret double %sub

$ ./clang -march=haswell -O1 -ffast-math -fomit-frame-pointer fadd.c -S -o -
     .quad    -4616189618054758400    ## double -1
     .quad    -4611686018427387904    ## double -2
     vmovsd    LCPI0_0(%rip), %xmm2
     vsubsd    %xmm0, %xmm2, %xmm0
     vsubsd    %xmm1, %xmm0, %xmm0
     vaddsd    LCPI0_1(%rip), %xmm0, %xmm0


This should be reassociated/combined to "-3.0 - x - y" (one constant, two

     vmovsd    LCPI0_0(%rip), %xmm2
     vsubsd    %xmm0, %xmm2, %xmm3
     vsubsd    %xmm1, %xmm3, %xmm0

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/20141218/37d5ba75/attachment.html>

More information about the llvm-bugs mailing list