|
10 | 10 |
|
11 | 11 | use crate::core_arch::powerpc::*; |
12 | 12 | use crate::core_arch::simd::*; |
| 13 | +use super::macros::*; |
13 | 14 |
|
14 | 15 | #[cfg(test)] |
15 | 16 | use stdarch_test::assert_instr; |
@@ -173,6 +174,10 @@ mod sealed { |
173 | 174 | vec_mergeeo! { vector_float, mergee, mergeo } |
174 | 175 | } |
175 | 176 |
|
| 177 | +// Implement AltiVec's VectorSld trait for vector_double to enable vec_sld support |
| 178 | +use crate::core_arch::powerpc::altivec::sealed::{VectorSld, vsldoi, xxsldwi}; |
| 179 | +impl_vec_sld! { vector_double } |
| 180 | + |
176 | 181 | /// Vector permute. |
177 | 182 | #[inline] |
178 | 183 | #[target_feature(enable = "vsx")] |
@@ -255,4 +260,24 @@ mod tests { |
255 | 260 | test_vec_xxpermdi! {test_vec_xxpermdi_i64x2, i64x2, vector_signed_long, [0], [-1], [2], [-3]} |
256 | 261 | test_vec_xxpermdi! {test_vec_xxpermdi_m64x2, m64x2, vector_bool_long, [false], [true], [false], [true]} |
257 | 262 | test_vec_xxpermdi! {test_vec_xxpermdi_f64x2, f64x2, vector_double, [0.0], [1.0], [2.0], [3.0]} |
| 263 | + |
| 264 | + #[simd_test(enable = "altivec")] |
| 265 | + fn test_vec_sld_f64x2() { |
| 266 | + use crate::core_arch::powerpc::altivec::sealed::VectorSld; |
| 267 | + |
| 268 | + let a = vector_double::from(f64x2::from_array([1.0, 2.0])); |
| 269 | + let b = vector_double::from(f64x2::from_array([3.0, 4.0])); |
| 270 | + |
| 271 | + // Shift left by 8 bytes (1 f64 element) |
| 272 | + // On little-endian: shifts right in memory, result is [b[1], a[0]] = [4.0, 1.0] |
| 273 | + // On big-endian: shifts left in memory, result is [a[1], b[0]] = [2.0, 3.0] |
| 274 | + unsafe { |
| 275 | + let result: f64x2 = transmute(a.vec_sld::<8>(b)); |
| 276 | + #[cfg(target_endian = "little")] |
| 277 | + let expected = f64x2::from_array([4.0, 1.0]); |
| 278 | + #[cfg(target_endian = "big")] |
| 279 | + let expected = f64x2::from_array([2.0, 3.0]); |
| 280 | + assert_eq!(result, expected); |
| 281 | + } |
| 282 | + } |
258 | 283 | } |
0 commit comments