<html>
    <head>
      <base href="https://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 --- - failure to convert FP addition loop into a constant"
   href="https://llvm.org/bugs/show_bug.cgi?id=27899">27899</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>failure to convert FP addition loop into a constant
          </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>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If we continue on the path from the realistic (<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Code explosion when LoopVectorize vectorizes a loop with a stride of 8 floats, part 2"
   href="show_bug.cgi?id=27881">bug 27881</a>, <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - failure to convert FP addition loop into multiplication with fast-math"
   href="show_bug.cgi?id=27894">bug 27894</a>) to the
absurd, I think we end here. :)

float OneMeelion() {
  float sum = 0.0f;
  for (int i = 0; i < 1000; i++)
    sum += 1000.0f;

  return sum;
}

We don't need fast-math to know this answer.

$ ./clang -O2 OneMeelion.c -S -o -
...
    xorps    %xmm0, %xmm0
    movl    $1000, %eax             ## imm = 0x3E8
    movss    LCPI0_0(%rip), %xmm1    ## xmm1 = mem[0],zero,zero,zero
    .p2align    4, 0x90
LBB0_1:                                 ## %for.body
                                        ## =>This Inner Loop Header: Depth=1
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addl    $-10, %eax
    jne    LBB0_1


Surprisingly, this didn't vectorize!

That's because "-Rpass-analysis=loop-vectorize":
remark: loop not vectorized: cannot prove it is safe to reorder floating-point
operations</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>