Skip to content

Commit 410f295

Browse files
committed
Add Altivec vec_floor
1 parent 348558e commit 410f295

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ extern "C" {
239239

240240
#[link_name = "llvm.ppc.altivec.vexptefp"]
241241
fn vexptefp(a: vector_float) -> vector_float;
242+
243+
#[link_name = "llvm.floor.v4f32"]
244+
fn vfloor(a: vector_float) -> vector_float;
242245
}
243246

244247
macro_rules! s_t_l {
@@ -409,6 +412,8 @@ mod sealed {
409412
}
410413
}
411414

415+
test_impl! { vec_floor(a: vector_float) -> vector_float [ vfloor, vrfim / xvrspim ] }
416+
412417
test_impl! { vec_vexptefp(a: vector_float) -> vector_float [ vexptefp, vexptefp ] }
413418

414419
test_impl! { vec_vcmpgtub(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_bool_char [ vcmpgtub, vcmpgtub ] }
@@ -1371,6 +1376,13 @@ mod sealed {
13711376
vector_mladd! { vector_signed_short, vector_signed_short, vector_signed_short }
13721377
}
13731378

1379+
/// Vector floor.
1380+
#[inline]
1381+
#[target_feature(enable = "altivec")]
1382+
pub unsafe fn vec_floor(a: vector_float) -> vector_float {
1383+
sealed::vec_floor(a)
1384+
}
1385+
13741386
/// Vector expte.
13751387
#[inline]
13761388
#[target_feature(enable = "altivec")]
@@ -1800,6 +1812,11 @@ mod tests {
18001812
}
18011813
}
18021814

1815+
test_vec_1! { test_vec_floor, vec_floor, f32x4,
1816+
[1.1, 1.9, -0.5, -0.9],
1817+
[1.0, 1.0, -1.0, -1.0]
1818+
}
1819+
18031820
test_vec_1! { test_vec_expte, vec_expte, f32x4,
18041821
[0.0, 2.0, 2.0, -1.0],
18051822
~[1.0, 4.0, 4.0, 0.5]

0 commit comments

Comments
 (0)