<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 --- - Missing loop canonicalization when iterating using a pointer or an integer index"
   href="https://llvm.org/bugs/show_bug.cgi?id=27395">27395</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing loop canonicalization when iterating using a pointer or an integer index
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mehdi.amini@apple.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>Considering this simple example:

int data[8000];
int init_value;
void foo() {
    auto *start = data;
    while (start++ != data+8000)
        *start = init_value;
}
void bar() {
    for (int i = 0; i < 8000; i++)
        data[i] = init_value;
}



foo() and bar() are performing the same initialization of array `data`, however
foo() is iterating using a sliding pointer while bar() is using an integer
index.
I would expect us to canonicalize the iterator one way or the other.

Right now, we can only vectorize the second form. It seems to be because the
first form iterates using a pointer, it compares to the end of the array using:

  %4 = icmp ne i32* %2, getelementptr inbounds (i32* getelementptr inbounds
([8000 x i32]* @data, i32 0, i32 0), i64 8000)

This GEP prevents global alias analysis from doing anything interesting with
data (i. (Here it seems that "data" is not detected to not alias with
`init_value`...), see GlobalsAAResult::AnalyzeUsesOfPointer().</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>