Skip to content

Commit 7986c50

Browse files
committed
Auto merge of #146683 - clarfonthey:safe-intrinsics, r=RalfJung,Amanieu
Mark float intrinsics with no preconditions as safe Note: for ease of reviewing, the list of safe intrinsics is sorted in the first commit, and then safe intrinsics are added in the second commit. All *recently added* float intrinsics have been correctly marked as safe to call due to the fact that they have no preconditions. This adds the remaining float intrinsics which are safe to call to the safe intrinsic list, and removes the unsafe blocks around their calls. --- Side note: this may want a try run before being added to the queue, since I'm not sure if there's any tier-2 code that uses these intrinsics that might not be tested on the usual PR flow. We've already uncovered a few places in subtrees that do this, and it's worth double-checking before clogging up the queue.
2 parents 4b28357 + ab5a73a commit 7986c50

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/pass/float.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,12 +1415,12 @@ fn test_fmuladd() {
14151415

14161416
#[inline(never)]
14171417
pub fn test_operations_f32(a: f32, b: f32, c: f32) {
1418-
assert_approx_eq!(unsafe { fmuladdf32(a, b, c) }, a * b + c);
1418+
assert_approx_eq!(fmuladdf32(a, b, c), a * b + c);
14191419
}
14201420

14211421
#[inline(never)]
14221422
pub fn test_operations_f64(a: f64, b: f64, c: f64) {
1423-
assert_approx_eq!(unsafe { fmuladdf64(a, b, c) }, a * b + c);
1423+
assert_approx_eq!(fmuladdf64(a, b, c), a * b + c);
14241424
}
14251425

14261426
test_operations_f32(0.1, 0.2, 0.3);

tests/pass/intrinsics/fmuladd_nondeterministic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
let c = std::hint::black_box(-a * b);
2929
// It is unspecified whether the following operation is fused or not. The
3030
// following evaluates to 0.0 if unfused, and nonzero (-1.66e-18) if fused.
31-
let x = unsafe { fmuladdf64(a, b, c) };
31+
let x = fmuladdf64(a, b, c);
3232
x == 0.0
3333
}),
3434
"`fmuladdf64` failed to be evaluated as both fused and unfused"
@@ -41,7 +41,7 @@ fn main() {
4141
let c = std::hint::black_box(-a * b);
4242
// It is unspecified whether the following operation is fused or not. The
4343
// following evaluates to 0.0 if unfused, and nonzero (-8.1956386e-10) if fused.
44-
let x = unsafe { fmuladdf32(a, b, c) };
44+
let x = fmuladdf32(a, b, c);
4545
x == 0.0
4646
}),
4747
"`fmuladdf32` failed to be evaluated as both fused and unfused"

0 commit comments

Comments
 (0)