<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/99734>99734</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [LV] missed optimization with pragma assume_safety
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vfdff
      </td>
    </tr>
</table>

<pre>
    * I defined 2 function **Map_Center_Of_Mass_CPU** and **foo_noalias**, we can see the only different is that the function **foo_noalias** has extra **__restrict__** for the argument  **int * crd**. According [Control-auto-vectorization-with-pragmas](https://developer.arm.com/documentation/101458/2404/Optimize/Control-auto-vectorization-with-pragmas), the **#pragma clang loop vectorize(assume_safety)** can assume there is no data dependencies for the following loop, so I expected they have similar output assemble , and now only the function **foo_noalias** can vectorize succcessfully.

> The preceding pragma indicates to the compiler that the following loop contains no data dependencies between loop iterations that would prevent vectorization. The compiler might be able to use this information to vectorize a loop, where it would not typically be possible

* test: https://gcc.godbolt.org/z/sjThWPs9f
```
void Map_Center_Of_Mass_CPU(int residue_i, int *start,  int *end, int * crd)
{
    #pragma clang loop vectorize(assume_safety)
    for (int atom_i = start[residue_i]; atom_i < end[residue_i]; atom_i++)
    {
 crd[atom_i] = crd[atom_i] + 8;
    }
}


void foo_noalias (int residue_i, int *start,  int *end, int * __restrict__ crd)
{
 #pragma clang loop vectorize(assume_safety)
    for (int atom_i = start[residue_i]; atom_i < end[residue_i]; atom_i++)
    {
 crd[atom_i] = crd[atom_i] + 8;
    }
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkVU-P27gP_TTKhZjAke1JfPAhf34BCvyK9tDdPRqyRMcqZMmQ6KSZT7-Q7UySFgN0sccFjMSWKL7HR1IUIeiTRSxZvmP5YSEGap0vz41qmkXt1LVkfAufQGGjLSrg0AxWknYWGN8yvv0s-mqPltBXX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