<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/127176>127176</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
【opt】incorrect oupput dependence in loop interchange pass
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shanksjoe
</td>
</tr>
</table>
<pre>
```
void test(float *indices, float init_i, int M, int K) {
if (M < 0 || K < 0)
return;
for (int j = 0; j < K; ++j) {
for (int i = 0; i < M; ++i) {
indices[i * K + j] = init_i + i;
}
}
}
```
```
$ clang test.c -O2 -S -emit-llvm -floop-interchange -mllvm -debug-only=loop-interchange
Processing LoopList of size = 2
Found 1 Loads and Stores to analyze
Found output dependency between Src and Dst
Src: store float %add, ptr %arrayidx, align 4, !tbaa !7
Dst: store float %add, ptr %arrayidx, align 4, !tbaa !7
Dependency matrix before interchange:
* *
Processing InnerLoopId = 1 and OuterLoopId = 0
Failed interchange InnerLoopId = 1 and OuterLoopId = 0 due to dependence
Not interchanging loops. Cannot prove legality.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE2P4ygQ_TXlS8kRxl_JwYd8bKRRd--s1D9ghU3FIUvAAtwzmV-_gnQ6yZ72MFIUHmXeo-pVCeG9Gg1RB_UG6l0m5nC0rvNHYf7xJ0tZb-Wlg4Z9_tj6wyqJgXwAvjxoKwICXysj1UAe-BavMWVU-FvFvTIB327gBfgKod0AWyOqAwJfviGUW2QI7RbaLb5ct8BX6QyiozA7A-WVc7AukqLWCaHcIYNyk-AWXyIEvgG-OT3e88RSd5ZKrLc7Sz2zEG9l1RsVq4zJ8Q2eoN4llWuRKaZuCSJCu0voun7-Pxj4hHmFgxZmTI4uBsy_c8zfMaezCrnWH2fMD9raKVcmkBuOwoyE-fn6RVI_j7k1-gLl7r-ngK3_cnYg75UZ8dXa6VX5gPaAXv2ilD8Htt7b2Ugs8NUK6VEYie_BOvIYLAoj9OUXfZ2yc5jmgJImMpLMcMGewg8ig-9uSNydD7H2dzdAuUb0UQpvU1ILKeMgTMGlnXPiouTPGBJajQarCIEXoRcirm3UipK_SWt3T_wsglM_sadDVH20rVynvqxTw59N_GYMuejkN5n8K1LN3-fwFI193QulST7q_l8yypmi918mR_v_tOFBK6YSu-0XuBXG2ICTsx-EmkahVbgsHocsk10pV-VKZNQVbbmqi2Xdltmxkz3r5bJs5JJ43_Si4dWqL5dN1ddDMRQ8Ux1nvGa8qFhbNkW5GKhvmqZhdVU0w6FiUDE6C6UXcRoX1o2Z8n6mruBt0TaZFj1pnx4Wzg39wPQVOI_vjOsiKe_n0UPFtPLB32WCCpo6-KOEJYMVs1O44UKZwTpHQ0A7T0_DGLuYbHlyfRLeZ7PT3TGEycfm8j3w_ajCce4Xgz0D38d7P5d8cvZEQwC-T9l64PvPcj46_m8AAAD__8pWkYM">