Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement [T]::align_to #50319

Merged
merged 4 commits into from
May 19, 2018
Merged

Implement [T]::align_to #50319

merged 4 commits into from
May 19, 2018

Commits on May 17, 2018

  1. 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.
    nagisa committed May 17, 2018
    Configuration menu
    Copy the full SHA
    d453782 View commit details
    Browse the repository at this point in the history
  2. Implement [T]::align_to

    nagisa committed May 17, 2018
    Configuration menu
    Copy the full SHA
    680031b View commit details
    Browse the repository at this point in the history
  3. Remove the intrinsic for align_offset

    Keep only the language item. This removes some indirection and makes
    codegen worse for debug builds, but simplifies code significantly, which
    is a good tradeoff to make, in my opinion.
    
    Besides, the codegen can be improved even further with some constant
    evaluation improvements that we expect to happen in the future.
    nagisa committed May 17, 2018
    Configuration menu
    Copy the full SHA
    6d5bf8b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    59bb0fe View commit details
    Browse the repository at this point in the history