Skip to content

Commit 1ee97ae

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 92f088e + 38cebba commit 1ee97ae

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

crates/core_arch/src/aarch64/neon/generated.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10306,7 +10306,7 @@ pub fn vfmad_lane_f64<const LANE: i32>(a: f64, b: f64, c: float64x1_t) -> f64 {
1030610306
#[unstable(feature = "stdarch_neon_f16", issue = "136306")]
1030710307
#[cfg(not(target_arch = "arm64ec"))]
1030810308
pub fn vfmah_f16(a: f16, b: f16, c: f16) -> f16 {
10309-
unsafe { fmaf16(b, c, a) }
10309+
fmaf16(b, c, a)
1031010310
}
1031110311
#[doc = "Floating-point fused multiply-add to accumulator"]
1031210312
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vfmah_lane_f16)"]
@@ -22448,7 +22448,7 @@ pub fn vrndaq_f64(a: float64x2_t) -> float64x2_t {
2244822448
#[cfg(not(target_arch = "arm64ec"))]
2244922449
#[cfg_attr(test, assert_instr(frinta))]
2245022450
pub fn vrndah_f16(a: f16) -> f16 {
22451-
unsafe { roundf16(a) }
22451+
roundf16(a)
2245222452
}
2245322453
#[doc = "Floating-point round to integral, to nearest with ties to away"]
2245422454
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vrndh_f16)"]
@@ -22458,7 +22458,7 @@ pub fn vrndah_f16(a: f16) -> f16 {
2245822458
#[cfg(not(target_arch = "arm64ec"))]
2245922459
#[cfg_attr(test, assert_instr(frintz))]
2246022460
pub fn vrndh_f16(a: f16) -> f16 {
22461-
unsafe { truncf16(a) }
22461+
truncf16(a)
2246222462
}
2246322463
#[doc = "Floating-point round to integral, using current rounding mode"]
2246422464
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vrndi_f16)"]
@@ -22639,7 +22639,7 @@ pub fn vrndmq_f64(a: float64x2_t) -> float64x2_t {
2263922639
#[cfg(not(target_arch = "arm64ec"))]
2264022640
#[cfg_attr(test, assert_instr(frintm))]
2264122641
pub fn vrndmh_f16(a: f16) -> f16 {
22642-
unsafe { floorf16(a) }
22642+
floorf16(a)
2264322643
}
2264422644
#[doc = "Floating-point round to integral, to nearest with ties to even"]
2264522645
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vrndn_f64)"]
@@ -22770,7 +22770,7 @@ pub fn vrndpq_f64(a: float64x2_t) -> float64x2_t {
2277022770
#[cfg(not(target_arch = "arm64ec"))]
2277122771
#[cfg_attr(test, assert_instr(frintp))]
2277222772
pub fn vrndph_f16(a: f16) -> f16 {
22773-
unsafe { ceilf16(a) }
22773+
ceilf16(a)
2277422774
}
2277522775
#[doc = "Floating-point round to integral exact, using current rounding mode"]
2277622776
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vrndx_f16)"]
@@ -24268,7 +24268,7 @@ pub fn vsqrtq_f64(a: float64x2_t) -> float64x2_t {
2426824268
#[cfg(not(target_arch = "arm64ec"))]
2426924269
#[cfg_attr(test, assert_instr(fsqrt))]
2427024270
pub fn vsqrth_f16(a: f16) -> f16 {
24271-
unsafe { sqrtf16(a) }
24271+
sqrtf16(a)
2427224272
}
2427324273
#[doc = "Shift Right and Insert (immediate)"]
2427424274
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_s8)"]

crates/core_arch/src/wasm32/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn unreachable() -> ! {
4343
#[must_use = "method returns a new number and does not mutate the original value"]
4444
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
4545
pub fn f32_ceil(a: f32) -> f32 {
46-
unsafe { crate::intrinsics::ceilf32(a) }
46+
crate::intrinsics::ceilf32(a)
4747
}
4848

4949
/// Generates the [`f32.floor`] instruction, returning the largest integer less than or equal to `a`.
@@ -57,7 +57,7 @@ pub fn f32_ceil(a: f32) -> f32 {
5757
#[must_use = "method returns a new number and does not mutate the original value"]
5858
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
5959
pub fn f32_floor(a: f32) -> f32 {
60-
unsafe { crate::intrinsics::floorf32(a) }
60+
crate::intrinsics::floorf32(a)
6161
}
6262

6363
/// Generates the [`f32.trunc`] instruction, roundinging to the nearest integer towards zero.
@@ -71,7 +71,7 @@ pub fn f32_floor(a: f32) -> f32 {
7171
#[must_use = "method returns a new number and does not mutate the original value"]
7272
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
7373
pub fn f32_trunc(a: f32) -> f32 {
74-
unsafe { crate::intrinsics::truncf32(a) }
74+
crate::intrinsics::truncf32(a)
7575
}
7676

7777
/// Generates the [`f32.nearest`] instruction, roundinging to the nearest integer. Rounds half-way
@@ -100,7 +100,7 @@ pub fn f32_nearest(a: f32) -> f32 {
100100
#[must_use = "method returns a new number and does not mutate the original value"]
101101
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
102102
pub fn f32_sqrt(a: f32) -> f32 {
103-
unsafe { crate::intrinsics::sqrtf32(a) }
103+
crate::intrinsics::sqrtf32(a)
104104
}
105105

106106
/// Generates the [`f64.ceil`] instruction, returning the smallest integer greater than or equal to `a`.
@@ -114,7 +114,7 @@ pub fn f32_sqrt(a: f32) -> f32 {
114114
#[must_use = "method returns a new number and does not mutate the original value"]
115115
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
116116
pub fn f64_ceil(a: f64) -> f64 {
117-
unsafe { crate::intrinsics::ceilf64(a) }
117+
crate::intrinsics::ceilf64(a)
118118
}
119119

120120
/// Generates the [`f64.floor`] instruction, returning the largest integer less than or equal to `a`.
@@ -128,7 +128,7 @@ pub fn f64_ceil(a: f64) -> f64 {
128128
#[must_use = "method returns a new number and does not mutate the original value"]
129129
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
130130
pub fn f64_floor(a: f64) -> f64 {
131-
unsafe { crate::intrinsics::floorf64(a) }
131+
crate::intrinsics::floorf64(a)
132132
}
133133

134134
/// Generates the [`f64.trunc`] instruction, roundinging to the nearest integer towards zero.
@@ -142,7 +142,7 @@ pub fn f64_floor(a: f64) -> f64 {
142142
#[must_use = "method returns a new number and does not mutate the original value"]
143143
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
144144
pub fn f64_trunc(a: f64) -> f64 {
145-
unsafe { crate::intrinsics::truncf64(a) }
145+
crate::intrinsics::truncf64(a)
146146
}
147147

148148
/// Generates the [`f64.nearest`] instruction, roundinging to the nearest integer. Rounds half-way
@@ -171,7 +171,7 @@ pub fn f64_nearest(a: f64) -> f64 {
171171
#[must_use = "method returns a new number and does not mutate the original value"]
172172
#[unstable(feature = "wasm_numeric_instr", issue = "133908")]
173173
pub fn f64_sqrt(a: f64) -> f64 {
174-
unsafe { crate::intrinsics::sqrtf64(a) }
174+
crate::intrinsics::sqrtf64(a)
175175
}
176176

177177
unsafe extern "C-unwind" {

crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,7 +3108,7 @@ intrinsics:
31083108
types:
31093109
- [f16, 'h_']
31103110
compose:
3111-
- FnCall: [roundf16, [a], [], true]
3111+
- FnCall: [roundf16, [a], []]
31123112

31133113
- name: "vrndn{neon_type.no}"
31143114
doc: "Floating-point round to integral, to nearest with ties to even"
@@ -3208,7 +3208,7 @@ intrinsics:
32083208
types:
32093209
- [f16, 'h_']
32103210
compose:
3211-
- FnCall: [floorf16, [a], [], true]
3211+
- FnCall: [floorf16, [a], []]
32123212

32133213

32143214

@@ -3257,7 +3257,7 @@ intrinsics:
32573257
types:
32583258
- [f16, 'h_']
32593259
compose:
3260-
- FnCall: [ceilf16, [a], [], true]
3260+
- FnCall: [ceilf16, [a], []]
32613261

32623262
- name: "vrnd{neon_type.no}"
32633263
doc: "Floating-point round to integral, toward zero"
@@ -3304,7 +3304,7 @@ intrinsics:
33043304
types:
33053305
- [f16, 'h_']
33063306
compose:
3307-
- FnCall: [truncf16, [a], [], true]
3307+
- FnCall: [truncf16, [a], []]
33083308

33093309

33103310
- name: "vrndi{neon_type.no}"
@@ -8499,7 +8499,7 @@ intrinsics:
84998499
types:
85008500
- [f16, 'h_']
85018501
compose:
8502-
- FnCall: [sqrtf16, [a], [], true]
8502+
- FnCall: [sqrtf16, [a], []]
85038503

85048504
- name: "vrsqrts{type[0]}"
85058505
doc: "Floating-point reciprocal square root step"
@@ -10464,7 +10464,7 @@ intrinsics:
1046410464
types:
1046510465
- ["f16", "h_f16"]
1046610466
compose:
10467-
- FnCall: [fmaf16, [b, c, a], [], true]
10467+
- FnCall: [fmaf16, [b, c, a], []]
1046810468

1046910469

1047010470
- name: "vfmah_lane{type[2]}"

0 commit comments

Comments
 (0)