Skip to content

Commit 2234a5d

Browse files
committed
Implement simd_round_ties_even for miri, cg_clif and cg_gcc
1 parent 4bcabb5 commit 2234a5d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/intrinsics/simd.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3737
| "ceil"
3838
| "floor"
3939
| "round"
40+
| "round_ties_even"
4041
| "trunc"
4142
| "fsqrt"
4243
| "fsin"
@@ -72,6 +73,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
7273
"ceil" => Op::Round(rustc_apfloat::Round::TowardPositive),
7374
"floor" => Op::Round(rustc_apfloat::Round::TowardNegative),
7475
"round" => Op::Round(rustc_apfloat::Round::NearestTiesToAway),
76+
"round_ties_even" => Op::Round(rustc_apfloat::Round::NearestTiesToEven),
7577
"trunc" => Op::Round(rustc_apfloat::Round::TowardZero),
7678
"ctlz" => Op::Numeric(sym::ctlz),
7779
"ctpop" => Op::Numeric(sym::ctpop),

tests/pass/intrinsics/portable-simd.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ fn simd_round() {
569569
f32x4::from_array([0.9, 1.001, 2.0, -4.5]).round(),
570570
f32x4::from_array([1.0, 1.0, 2.0, -5.0])
571571
);
572+
assert_eq!(
573+
unsafe { intrinsics::simd_round_ties_even(f32x4::from_array([0.9, 1.001, 2.0, -4.5])) },
574+
f32x4::from_array([1.0, 1.0, 2.0, -4.0])
575+
);
572576
assert_eq!(
573577
f32x4::from_array([0.9, 1.001, 2.0, -4.5]).trunc(),
574578
f32x4::from_array([0.0, 1.0, 2.0, -4.0])
@@ -586,6 +590,10 @@ fn simd_round() {
586590
f64x4::from_array([0.9, 1.001, 2.0, -4.5]).round(),
587591
f64x4::from_array([1.0, 1.0, 2.0, -5.0])
588592
);
593+
assert_eq!(
594+
unsafe { intrinsics::simd_round_ties_even(f64x4::from_array([0.9, 1.001, 2.0, -4.5])) },
595+
f64x4::from_array([1.0, 1.0, 2.0, -4.0])
596+
);
589597
assert_eq!(
590598
f64x4::from_array([0.9, 1.001, 2.0, -4.5]).trunc(),
591599
f64x4::from_array([0.0, 1.0, 2.0, -4.0])

0 commit comments

Comments
 (0)