rust/src
bors db41351753 Auto merge of #98866 - nagisa:nagisa/align-offset-wroom, r=Mark-Simulacrum
Add a special case for align_offset /w stride != 1

This generalizes the previous `stride == 1` special case to apply to any
situation where the requested alignment is divisible by the stride. This
in turn allows the test case from #98809 produce ideal assembly, along
the lines of:

    leaq 15(%rdi), %rax
    andq $-16, %rax

This also produces pretty high quality code for situations where the
alignment of the input pointer isn’t known:

    pub unsafe fn ptr_u32(slice: *const u32) -> *const u32 {
        slice.offset(slice.align_offset(16) as isize)
    }

    // =>

    movl %edi, %eax
    andl $3, %eax
    leaq 15(%rdi), %rcx
    andq $-16, %rcx
    subq %rdi, %rcx
    shrq $2, %rcx
    negq %rax
    sbbq %rax, %rax
    orq  %rcx, %rax
    leaq (%rdi,%rax,4), %rax

Here LLVM is smart enough to replace the `usize::MAX` special case with
a branch-less bitwise-OR approach, where the mask is constructed using
the neg and sbb instructions. This appears to work across various
architectures I’ve tried.

This change ends up introducing more branches and code in situations
where there is less knowledge of the arguments. For example when the
requested alignment is entirely unknown. This use-case was never really
a focus of this function, so I’m not particularly worried, especially
since llvm-mca is saying that the new code is still appreciably faster,
despite all the new branching.

Fixes #98809.
Sadly, this does not help with #72356.
2022-07-16 23:28:28 +00:00
..
bootstrap Don't build std for switch 2022-07-14 15:57:21 -04:00
ci Auto merge of #96978 - lqd:win_pgo2, r=Mark-Simulacrum 2022-07-11 20:32:06 +00:00
doc Rename aarch64-nintendo-switch to aarch64-nintendo-switch-freestanding 2022-07-14 15:58:26 -04:00
etc Rollup merge of #95446 - notseanray:master, r=Mark-Simulacrum 2022-06-22 15:16:08 +09:00
librustdoc Rollup merge of #99287 - GuillaumeGomez:rustdoc-json-double-export, r=notriddle 2022-07-16 22:30:51 +02:00
llvm-project@8b6b5014fd Update llvm-project 2022-07-05 17:57:29 +02:00
rustdoc-json-types Fix rustdoc JSON inline 2022-07-16 13:39:38 +02:00
test Auto merge of #98866 - nagisa:nagisa/align-offset-wroom, r=Mark-Simulacrum 2022-07-16 23:28:28 +00:00
tools Rollup merge of #99342 - TaKO8Ki:avoid-symbol-to-string-conversions, r=compiler-errors 2022-07-16 22:30:56 +02:00
README.md
stage0.json configure nightly branch name in stage0.json 2022-07-11 10:15:13 +02:00
version bump version to 1.64.0 2022-06-24 17:27:24 +02:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.