Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e940ba

Browse files
committed
Auto merge ofrust-lang#126578 - scottmcm:inlining-bonuses-too, r=davidtwco
Account for things that optimize out in inlining costsThis updates the MIR inlining `CostChecker` to have both bonuses and penalties, rather than just penalties.That lets us add bonuses for some things where we want to encourage inlining without risking wrapping into a gigantic cost. For example, `switchInt(const …)` we give an inlining bonus because codegen will actually eliminate the branch (and associated dead blocks) once it's monomorphized, so measuring both sides of the branch gives an unrealistically-high cost to it. Similarly, an `unreachable` terminator gets a small bonus, because whatever branch leads there doesn't actually exist post-codegen.
2 parents9a945fd +847726d commit7e940ba

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎core/src/slice/iter/macros.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ macro_rules! iterator {
103103
// so this new pointer is inside `self` and thus guaranteed to be non-null.
104104
unsafe{
105105
if_zst!(mutself,
106-
len =>*len = len.unchecked_sub(offset),
106+
// Using the intrinsic directly avoids emitting a UbCheck
107+
len =>*len =crate::intrinsics::unchecked_sub(*len, offset),
107108
_end =>self.ptr =self.ptr.add(offset),
108109
);
109110
}
@@ -119,7 +120,8 @@ macro_rules! iterator {
119120
// SAFETY: By our precondition, `offset` can be at most the
120121
// current length, so the subtraction can never overflow.
121122
len =>unsafe{
122-
*len = len.unchecked_sub(offset);
123+
// Using the intrinsic directly avoids emitting a UbCheck
124+
*len =crate::intrinsics::unchecked_sub(*len, offset);
123125
self.ptr
124126
},
125127
// SAFETY: the caller guarantees that `offset` doesn't exceed `self.len()`,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp