rust/library/core/src
Dylan DPC 8ed3a80b9a
Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc
Use a faster allocation size check in slice::from_raw_parts

I've been perusing through the codegen changes that result from turning on the standard library debug assertions. The previous check in here uses saturating arithmetic, which in my experience sometimes makes LLVM just fail to optimize things around the saturating operation.

Here is a demo of the codegen difference: https://godbolt.org/z/WMEqrjajW
Before:
```asm
example::len_check_old:
        mov     rax, rdi
        mov     ecx, 3
        mul     rcx
        setno   cl
        test    rax, rax
        setns   al
        and     al, cl
        ret

example::len_check_old:
        mov     rax, rdi
        mov     ecx, 8
        mul     rcx
        setno   cl
        test    rax, rax
        setns   al
        and     al, cl
        ret
```
After:
```asm
example::len_check_new:
        movabs  rax, 3074457345618258603
        cmp     rdi, rax
        setb    al
        ret

example::len_check_new:
        shr     rdi, 60
        sete    al
        ret
```

Running rustc-perf locally, this looks like up to a 4.5% improvement when `debug-assertions-std = true`.

Thanks ```@LegionMammal978``` (I think that's you?) for turning my idea into a much cleaner implementation.

r? ```@thomcc```
2022-10-26 11:29:53 +05:30
..
alloc
array Rollup merge of #100462 - zohnannor:master, r=thomcc 2022-10-23 14:48:13 -07:00
async_iter
cell
char Clarify the possible return values of len_utf16 2022-10-16 11:06:19 -04:00
convert
ffi
fmt
future
hash
iter specialize slice_iter.copied().next_chunk() 2022-10-19 00:02:00 +02:00
macros
mem MaybeUninit: use assume_init_drop() in the partially initialized array example 2022-10-23 19:09:18 +02:00
num Rollup merge of #101889 - tspiteri:redoc-uint-adc-sbb, r=m-ou-se 2022-10-18 21:18:46 +02:00
ops
panic Change tracking issue from #76156 to #102911 2022-10-11 06:40:37 +00:00
prelude
ptr Auto merge of #100848 - xfix:use-metadata-for-slice-len, r=thomcc 2022-10-24 04:14:46 +00:00
slice Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc 2022-10-26 11:29:53 +05:30
str Fix typo in ReverseSearcher docs 2022-10-17 13:14:15 -04:00
sync Remove extra spaces 2022-10-19 23:54:00 +01:00
task
unicode
any.rs
ascii.rs
asserting.rs
bool.rs
borrow.rs
cell.rs Rollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu 2022-10-16 11:41:12 +09:00
clone.rs
cmp.rs
const_closure.rs
default.rs
error.md
error.rs Stabilize duration_checked_float 2022-10-15 12:02:13 -07:00
hint.rs
internal_macros.rs
intrinsics.rs Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc 2022-10-26 11:29:53 +05:30
lib.rs Rollup merge of #103287 - saethlin:faster-len-check, r=thomcc 2022-10-26 11:29:53 +05:30
marker.rs PhantomData: inline a macro that is used only once 2022-10-16 10:37:51 +02:00
option.rs Rollup merge of #98204 - Kixiron:stable-unzip, r=thomcc 2022-10-25 14:43:13 +05:30
panic.rs
panicking.rs reorder panicking.rs to put main entry points at the top 2022-10-11 22:47:31 +02:00
pin.rs
primitive_docs.rs
primitive.rs
result.rs
time.rs Stabilize duration_checked_float 2022-10-15 12:02:13 -07:00
tuple.rs
unit.rs