Skip to content

Commit 3b6179b

Browse files
committed
Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #124570 (Miscellaneous cleanups) - #124772 (Refactor documentation for Apple targets) - #125011 (Add opt-for-size core lib feature flag) - #125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`) - #125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS) - #125266 (compiler: add simd_ctpop intrinsic) - #125348 (Small fixes to `std::path::absolute` docs) Failed merges: - #125296 (Fix `unexpected_cfgs` lint on std) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ff11eae + 49c9cf5 commit 3b6179b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/intrinsics/simd.rs

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4242
| "flog2"
4343
| "flog10"
4444
| "ctlz"
45+
| "ctpop"
4546
| "cttz"
4647
| "bswap"
4748
| "bitreverse"
@@ -68,6 +69,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6869
"round" => Op::Round(rustc_apfloat::Round::NearestTiesToAway),
6970
"trunc" => Op::Round(rustc_apfloat::Round::TowardZero),
7071
"ctlz" => Op::Numeric(sym::ctlz),
72+
"ctpop" => Op::Numeric(sym::ctpop),
7173
"cttz" => Op::Numeric(sym::cttz),
7274
"bswap" => Op::Numeric(sym::bswap),
7375
"bitreverse" => Op::Numeric(sym::bitreverse),

tests/pass/intrinsics/portable-simd.rs

+15
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,21 @@ fn simd_intrinsics() {
505505
assert!(simd_reduce_all(i32x4::splat(-1)));
506506
assert!(!simd_reduce_all(i32x2::from_array([0, -1])));
507507

508+
assert_eq!(
509+
simd_ctlz(i32x4::from_array([0, i32::MAX, i32::MIN, -1_i32])),
510+
i32x4::from_array([32, 1, 0, 0])
511+
);
512+
513+
assert_eq!(
514+
simd_ctpop(i32x4::from_array([0, i32::MAX, i32::MIN, -1_i32])),
515+
i32x4::from_array([0, 31, 1, 32])
516+
);
517+
518+
assert_eq!(
519+
simd_cttz(i32x4::from_array([0, i32::MAX, i32::MIN, -1_i32])),
520+
i32x4::from_array([32, 0, 31, 0])
521+
);
522+
508523
assert_eq!(
509524
simd_select(i8x4::from_array([0, -1, -1, 0]), a, b),
510525
i32x4::from_array([1, 10, 10, 4])

0 commit comments

Comments
 (0)