<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 --- - Store overwritten in next loop iteration is not eliminated"
   href="http://llvm.org/bugs/show_bug.cgi?id=18849">18849</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Store overwritten in next loop iteration is not eliminated
          </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>Linux
          </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>tobias@grosser.es
          </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>Created <span class=""><a href="attachment.cgi?id=12065" name="attach_12065" title="The LLVM-IR file to reproduce this bug">attachment 12065</a> <a href="attachment.cgi?id=12065&action=edit" title="The LLVM-IR file to reproduce this bug">[details]</a></span>
The LLVM-IR file to reproduce this bug

This loop contains a store that is overwritten right in the next loop iteration
and the store in the last loop iteration is overwritten right after the loop.
So the store is fully redundant.

void f(float *restrict A, float *restrict B, long N) {
  B[0] = A[0];
  for (long i = 1; i < N - 1; i += 1) {
    B[i - 1] += A[i]; 
    B[i] = A[i]; << This store is unneccessary
  }
  B[N - 2] += A[N - 1];
}

I would expect LLVM to eliminate this store.

The attached test case was slightly modified by removing the unnecessary reload
of 'B[N - 2] +=' to ensure that this load is not potentially obfuscating
the store right after the load.</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>