Commit f2244fd
Decompose byte_extract from union through widest member
When byte_extract is applied to a union-typed expression with a
non-constant computed offset, the byte_extract lowering creates a
massive expression because it must consider all possible byte layouts.
For unions where the widest member covers the entire union, we can
instead decompose the access through that member, avoiding the
expensive lowering.
Add union handling to the non-constant-offset overload of
get_subexpression_at_offset: for symbol and member expressions of
union type, recurse into the widest member. Guard this on the widest
member's size equalling the union's size (no trailing padding).
The constant-offset overload is left unchanged to preserve existing
simplification behavior (e.g., byte_extract(byte_update(...))
patterns used during constant propagation).
On the reproducer from #8813, the union version now takes 1.0s
(previously 94s), matching the struct version at 1.0s.
Fixes: #8813
Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>1 parent 6df204e commit f2244fd
3 files changed
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
862 | 888 | | |
863 | 889 | | |
864 | 890 | | |
| |||
0 commit comments