Commit b34136b
Fix GVN and SROA miscompilation of min precision vector element access
Multiple optimization passes mishandle min precision vector types due to
DXC's padded data layout (i16:32, f16:32), where getTypeSizeInBits
returns padded sizes for vectors but primitive sizes for scalars.
Bug 1 - GVN ICE: CanCoerceMustAliasedValueToLoad computes a padded
integer type (e.g., i96 for <3 x half>) then attempts to bitcast from
the 48-bit LLVM type, triggering an assert. Fix: reject coercion when
type sizes include padding.
Bug 2 - GVN incorrect store forwarding: processLoad forwards a 'store
<3 x i16> zeroinitializer' past partial element stores because
MemoryDependence uses padded sizes for aliasing. Fix: skip store-to-load
forwarding for padded types.
Bug 3 - SROA element misindexing: getNaturalGEPRecursively uses
getTypeSizeInBits (2 bytes for i16) for element offsets while GEP uses
getTypeAllocSize (4 bytes with i16:32). Byte offset 4 (element 1) maps
to index 4/2=2 instead of 4/4=1, causing SROA to misplace or eliminate
element stores. Fix: use getTypeAllocSizeInBits consistently for vector
element sizes throughout SROA.
Fixes microsoft#8268
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent fbc8aed commit b34136b
2 files changed
Lines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
853 | 853 | | |
854 | 854 | | |
855 | 855 | | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
856 | 870 | | |
857 | 871 | | |
858 | 872 | | |
| |||
1942 | 1956 | | |
1943 | 1957 | | |
1944 | 1958 | | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
1945 | 1970 | | |
1946 | 1971 | | |
1947 | 1972 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1671 | 1671 | | |
1672 | 1672 | | |
1673 | 1673 | | |
1674 | | - | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
1675 | 1679 | | |
1676 | 1680 | | |
1677 | 1681 | | |
| |||
2134 | 2138 | | |
2135 | 2139 | | |
2136 | 2140 | | |
2137 | | - | |
| 2141 | + | |
| 2142 | + | |
2138 | 2143 | | |
2139 | 2144 | | |
2140 | 2145 | | |
| |||
2492 | 2497 | | |
2493 | 2498 | | |
2494 | 2499 | | |
2495 | | - | |
| 2500 | + | |
| 2501 | + | |
2496 | 2502 | | |
2497 | 2503 | | |
2498 | 2504 | | |
2499 | 2505 | | |
2500 | | - | |
| 2506 | + | |
2501 | 2507 | | |
2502 | 2508 | | |
2503 | 2509 | | |
| |||
0 commit comments