Skip to content

Commit

Permalink
Rollup merge of #122461 - the8472:fix-step-forward-unchecked, r=Amanieu
Browse files Browse the repository at this point in the history
fix unsoundness in Step::forward_unchecked for signed integers

Fixes #122420

```rust
pub fn foo(a: i8, b: u8) -> i8 {
    unsafe { a.checked_add_unsigned(b).unwrap_unchecked() }
}
```

still compiles down to a single arithmetic instruction ([godbolt](https://rust.godbolt.org/z/qsd3xYWfE)).

But we may be losing some loop optimizations if llvm can no longer easily derive that it's a finite counted loop from the no-wrapping flags.
  • Loading branch information
matthiaskrgr authored Mar 14, 2024
2 parents 0398886 + fbf7a93 commit bb0136e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/pass/shims/time-with-isolation2.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The loop took around 7s
The loop took around 12s

0 comments on commit bb0136e

Please sign in to comment.