Commit 3487fba
committed
fix(compiler): dynamic array indexing on function parameters
Two bugs fixed:
1. Array literal init with mixed const/non-const elements (mir/lower.ts):
When an array literal like [10000, 0, -10000, 0] had any non-int_lit element,
the fallback path initialised the whole array to zeros and then only patched
non-literal (dynamic) slots. Non-zero int_lit values at any position were
silently left as 0.
Fix: pre-populate the 'set value [...]' with actual int_lit values; skip only
the purely-zero slots, and emit nbt_write only for the remaining dynamic elems.
2. Interprocedural const-prop did not substitute nbt_read_dynamic.indexSrc
(optimizer/interprocedural.ts):
The substituteInstr switch had no case for nbt_read_dynamic / nbt_write_dynamic,
so when a callee was specialised with a constant index (e.g. dft_magnitude(re,im,1)),
the index operand inside the specialised function stayed as the unset param temp
(value 0) instead of the concrete constant (1).
Fix: add cases for both nbt_read_dynamic and nbt_write_dynamic so indexSrc and
valueSrc are properly substituted.
Together these fix DFT/FFT-style functions that pass int[] parameters and index
them with a runtime variable or a call-site constant argument.1 parent ddd0b39 commit 3487fba
3 files changed
Lines changed: 83 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
591 | | - | |
592 | | - | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
593 | 595 | | |
| 596 | + | |
594 | 597 | | |
595 | | - | |
596 | | - | |
597 | | - | |
| 598 | + | |
598 | 599 | | |
599 | 600 | | |
600 | 601 | | |
| |||
1338 | 1339 | | |
1339 | 1340 | | |
1340 | 1341 | | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1341 | 1372 | | |
1342 | 1373 | | |
1343 | 1374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
| |||
0 commit comments