diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2018-04-18 18:38:12 +0300 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2018-05-17 22:46:02 +0300 |
| commit | d45378216b31eab9ee7c7c461ae20bfb29bd20b3 (patch) | |
| tree | a877f965ad968a4fb32bd5f54d9b3e75de7c613d /src/rustllvm/RustWrapper.cpp | |
| parent | 90463a6bdcd18c60e18a1cc810fc6453b96f7d54 (diff) | |
| download | rust-d45378216b31eab9ee7c7c461ae20bfb29bd20b3.tar.gz rust-d45378216b31eab9ee7c7c461ae20bfb29bd20b3.zip | |
Change align_offset to support different strides
This is necessary if we want to implement `[T]::align_to` and is more useful in general. This implementation effort has begun during the All Hands and represents a month of my futile efforts to do any sort of maths. Luckily, I found the very very nice Chris McDonald (cjm) on IRC who figured out the core formulas for me! All the thanks for existence of this PR go to them! Anyway… Those formulas were mangled by yours truly into the arcane forms you see here to squeeze out the best assembly possible on most of the modern architectures (x86 and ARM were evaluated in practice). I mean, just look at it: *one actual* modulo operation and everything else is just the cheap single cycle ops! Admitedly, the naive solution might be faster in some common scenarios, but this code absolutely butchers the naive solution on the worst case scenario. Alas, the result of this arcane magic also means that the code pretty heavily relies on the preconditions holding true and breaking those preconditions will unleash the UB-est of all UBs! So don’t.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
