Commit 4c3f77a
committed
inference: form
This commit forms `PartialStruct` whenever there is any type-level
refinement available about a field, even if it's not "constant" information.
In Julia "definitions" are allowed to be abstract whereas "usages"
(i.e. callsites) are often concrete. The basic idea is to allow inference
to make more use of such precise callsite type information by encoding it
as `PartialStruct`.
This may increase optimization possibilities of "unidiomatic" Julia code,
which may contain poorly-typed definitions, like this very contrived example:
```julia
struct Problem
n; s; c; t
end
function main(args...)
prob = Problem(args...)
s = 0
for i in 1:prob.n
m = mod(i, 3)
s += m == 0 ? sin(prob.s) : m == 1 ? cos(prob.c) : tan(prob.t)
end
return prob, s
end
main(10000, 1, 2, 3)
```
One of the obvious limitation is that this extra type information can be
propagated inter-procedurally only as a const-propagation.
I'm not sure this kind of "just a type-level" refinement can often make
constant-prop' successful (i.e. shape-up a method body and allow it to
be inlined, encoding the extra type information into the generated code),
thus I didn't not modify any part of const-prop' heuristics.
So the improvements from this change is almost for local analysis,
and for very simple inter-procedural calls.PartialStruct for extra type information propagation1 parent c054dbc commit 4c3f77a
File tree
4 files changed
+50
-27
lines changed- base/compiler
- test/compiler
4 files changed
+50
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1542 | 1542 | | |
1543 | 1543 | | |
1544 | 1544 | | |
1545 | | - | |
1546 | | - | |
| 1545 | + | |
| 1546 | + | |
1547 | 1547 | | |
1548 | 1548 | | |
1549 | 1549 | | |
1550 | | - | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
1551 | 1555 | | |
1552 | 1556 | | |
1553 | 1557 | | |
1554 | 1558 | | |
1555 | | - | |
| 1559 | + | |
1556 | 1560 | | |
1557 | 1561 | | |
1558 | 1562 | | |
1559 | 1563 | | |
1560 | | - | |
| 1564 | + | |
1561 | 1565 | | |
1562 | 1566 | | |
1563 | 1567 | | |
| |||
1569 | 1573 | | |
1570 | 1574 | | |
1571 | 1575 | | |
1572 | | - | |
| 1576 | + | |
1573 | 1577 | | |
1574 | 1578 | | |
1575 | 1579 | | |
| |||
1741 | 1745 | | |
1742 | 1746 | | |
1743 | 1747 | | |
1744 | | - | |
| 1748 | + | |
1745 | 1749 | | |
1746 | 1750 | | |
1747 | 1751 | | |
1748 | | - | |
1749 | | - | |
1750 | | - | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
1751 | 1759 | | |
1752 | 1760 | | |
1753 | 1761 | | |
1754 | | - | |
| 1762 | + | |
1755 | 1763 | | |
1756 | 1764 | | |
1757 | 1765 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3645 | 3645 | | |
3646 | 3646 | | |
3647 | 3647 | | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
430 | 432 | | |
431 | | - | |
| 433 | + | |
432 | 434 | | |
433 | 435 | | |
434 | 436 | | |
435 | 437 | | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 438 | + | |
444 | 439 | | |
445 | 440 | | |
446 | | - | |
447 | | - | |
| 441 | + | |
| 442 | + | |
448 | 443 | | |
449 | 444 | | |
450 | 445 | | |
451 | 446 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | 447 | | |
0 commit comments