Commit ff39274
committed
fix(compiler): carry vector operands through inlining and CSE
Two passes walk an instruction's operands by hand and end the match
with a catch-all, and the vector family fell into it. Both were live
miscompiles, found writing a tensor kernel in ZynML.
Inlining substitutes the id an instruction defines so a cloned body
lands on fresh values, and its list of instructions that define
something named none of the vector ops. An inlined `vector_splat` kept
the id it had in the callee while every use of it moved to the fresh
one, so `vstore` wrote a value nothing had computed. A store inside a
called function silently did nothing and the kernel read back zero.
CSE rewrites the uses of an instruction it eliminates, over thirteen
kinds and no vector ones. Eliminating a redundant `extractvalue` left a
`vload` pointing at an id that no longer existed, which Cranelift met
as "arg not in value_map".
`HirInstruction::replace_uses` covers all nine ops and is the one to
reach for. These went unnoticed because vectorised code stays inside
the function that produced it, so neither pass had met a vector op
until one was written by hand.1 parent 67a8bff commit ff39274
2 files changed
Lines changed: 39 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
571 | 597 | | |
572 | 598 | | |
573 | 599 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
1344 | | - | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
1345 | 1357 | | |
1346 | 1358 | | |
1347 | 1359 | | |
| |||
0 commit comments