We’ve regressed in removing null checks. Some performance oriented code like itertools::Stride and itertools::ZipSlices now fall prey to llvm being doubtful of nonnullity and inserting extra checks.
The end effect is that loops that otherwise looked good to llvm now are not recognized. When loop transformations like unrolling and autovectorization are not available, the impact on performance may be 5x or more.
libstd works around this by liberal use of
assume, which is an unstable intrinsic, so regular stable rust has no real recourse. I suppose it’s a bug that we can fix though.
Most of the affected code uses
<[_]>::get_unchecked() or similar. I’ve also seen some cases of having an iterator derived from
&Vec compile file while derived from
& it fell into this null check trap (code link)