forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#103299 - nikic:usub-overflow, r=wesleywiser
Don't use usub.with.overflow intrinsic The canonical form of a usub.with.overflow check in LLVM are separate sub + icmp instructions, rather than a usub.with.overflow intrinsic. Using usub.with.overflow will generally result in worse optimization potential. The backend will attempt to form usub.with.overflow when it comes to actual instruction selection. This is not fully reliable, but I believe this is a better tradeoff than using the intrinsic in IR. Fixes rust-lang#103285.
- Loading branch information
Showing
2 changed files
with
24 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// compile-flags: -O -C debug-assertions=yes | ||
|
||
#![crate_type = "lib"] | ||
#![feature(strict_provenance)] | ||
|
||
#[no_mangle] | ||
pub fn test(src: *const u8, dst: *const u8) -> usize { | ||
// CHECK-LABEL: @test( | ||
// CHECK-NOT: panic | ||
let src_usize = src.addr(); | ||
let dst_usize = dst.addr(); | ||
if src_usize > dst_usize { | ||
return src_usize - dst_usize; | ||
} | ||
return 0; | ||
} |