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

    <tr>
        <th>Summary</th>
        <td>
            [tests][AArch64] `gather_nxv4i32_ind64` in `test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll` depends on writing to `readonly` data
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    The `gather_nxv4i32_ind64` test seems to be depending on undefined behavior. The relevant part extracted:

```
define void @gather_nxv4i32_ind64_stride2(float* noalias nocapture readonly %a, float* noalias nocapture readonly %b, i64 %n) #0 {
    ...
    %arrayidx2 = getelementptr inbounds float, float* %a, i64 %indvars.iv
    store float %0, float* %arrayidx2, align 4
}
```

This is undefined behavior, as `%a` is marked `readonly` and therefore I believe it's not allowed to store through a pointer based on it. However, the GEP and store do store through it.

Unfortunately, removing the `readonly` causes this test to no longer vectorize. So I'm not sure what should be done here.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVMFunDAQ_Rq4jILAwLIcOGy6TRuph0pNe40MngW3XhvZhs326zuGoERpVHVlYWZn_ObN8wytEdfmYUCIdmnP_YD2UT_NhczZo9RiV9Df4NF5cIhnB95AiyBwRC2k7sFomLTAk9QoyDPwWRqbQAC0qHDm2sPIrQd88pZ3HkWUH6L0GKXbc5c-r8VcoWA2UkBUvMvo0XkrBbKI7U_KcB-xA2jDleSO9o6PfrIhOxdGqytErOQR-wD_GduGWLkrwruOWE17nkJU3a78gH5JkrwYAd5afpXiiUGUH6FHT4WfUfvRW5C6NSSQ29K_4rERe05Gtc3cukTOL-DOG6K3nAgh6V_nt8zBQVX1GopnWavju_quz4dBOqD199UtQC40w0KPLp_Cztz-ohiyNqWCg2sB4XbwFEjeE4SSOCNIYlcFeT1RUuZCJ6lr1lL8YM3UD8BhNFJ7tNByRwHURtIn8JmiZ1xIEDJ8-vh1ybKeFW9B6MTror5rIuInzUn_a4CweDZzaFK_tvdr8h2fHFI7ByGW9iaK2oAyuidSM3aUSf7GBL4ZuKd6zks9LnTLZaDbcIOZlFhmwVC_BhmSGJtst9uV2Y6xKhZNLuq85rGXXmETlbchj4vKI70eDrYbaLjK47_mTurgDccidvdguXZU4dmR8cWY8cdGkuwNj925GW9WvBvXcU8SJ0oFsHVmXZD6YqVfdDFvZRHc83iyqhm8H10YVXZHq5d-mNqkM2cylJq37Wa05ifRIFM6N2GgVu7LsoiHpmW1wIrV2SmruyrN07Ko8zyv9qzC7pRlseLUMS4IQzLEsmEpY1lK01bTs0oQiz1vy5aLsuBYZvQ1wDOXKgmJE2P72DYLh3bqHTmVJHVfnNw5GgfEDZ9PfjC2GbsLV97oeOHbLGT_AKXnmyE">