<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - FP constants not combined (fast-math)"
   href="http://llvm.org/bugs/show_bug.cgi?id=21962">21962</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>FP constants not combined (fast-math)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ 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 -
LCPI0_0:
     .quad    -4616189618054758400    ## double -1
LCPI0_1:
     .quad    -4611686018427387904    ## double -2
...
     vmovsd    LCPI0_0(%rip), %xmm2
     vsubsd    %xmm0, %xmm2, %xmm0
     vsubsd    %xmm1, %xmm0, %xmm0
     vaddsd    LCPI0_1(%rip), %xmm0, %xmm0
     retq

-----------------------------------------------------------------------

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

     vmovsd    LCPI0_0(%rip), %xmm2
     vsubsd    %xmm0, %xmm2, %xmm3
     vsubsd    %xmm1, %xmm3, %xmm0
     retq</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>