-
Notifications
You must be signed in to change notification settings - Fork 327
PowerPC: Add intrinsics support vec_add(vector_double, vector_double) #2161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
|
|
||
| use crate::core_arch::powerpc::*; | ||
| use crate::core_arch::simd::*; | ||
| use crate::intrinsics::simd::simd_add; | ||
|
|
||
| #[cfg(test)] | ||
| use stdarch_test::assert_instr; | ||
|
|
@@ -171,6 +172,27 @@ mod sealed { | |
| vec_mergeeo! { vector_unsigned_int, mergee, mergeo } | ||
| vec_mergeeo! { vector_bool_int, mergee, mergeo } | ||
| vec_mergeeo! { vector_float, mergee, mergeo } | ||
|
|
||
| #[inline] | ||
| #[target_feature(enable = "vsx")] | ||
| #[cfg_attr(test, assert_instr(xvadddp))] | ||
| pub(crate) unsafe fn vec_add_double_double( | ||
| a: vector_double, | ||
| b: vector_double, | ||
| ) -> vector_double { | ||
| simd_add(a, b) | ||
| } | ||
| } | ||
|
|
||
| // Implement AltiVec's VectorAdd trait for vector_double to enable vec_add support | ||
| #[unstable(feature = "stdarch_powerpc", issue = "111145")] | ||
| impl crate::core_arch::powerpc::altivec::sealed::VectorAdd<vector_double> for vector_double { | ||
| type Result = vector_double; | ||
| #[inline] | ||
| #[target_feature(enable = "vsx")] | ||
| unsafe fn vec_add(self, other: vector_double) -> Self::Result { | ||
| sealed::vec_add_double_double(self, other) | ||
| } | ||
| } | ||
|
Comment on lines
+187
to
196
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is the argument here that if you got your hands on a Because normally adding stricter target features on a trait method is error-prone: there is now an additional safety requirement on that trait method, which is that if that particular instance is called, the target feature must be enabled.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that was the idea. On PPC, vec_add(vector_double, vector_double) should result in code gen
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm yeah the |
||
|
|
||
| /// Vector permute. | ||
|
|
@@ -255,4 +277,15 @@ mod tests { | |
| test_vec_xxpermdi! {test_vec_xxpermdi_i64x2, i64x2, vector_signed_long, [0], [-1], [2], [-3]} | ||
| test_vec_xxpermdi! {test_vec_xxpermdi_m64x2, m64x2, vector_bool_long, [false], [true], [false], [true]} | ||
| test_vec_xxpermdi! {test_vec_xxpermdi_f64x2, f64x2, vector_double, [0.0], [1.0], [2.0], [3.0]} | ||
|
|
||
| #[simd_test(enable = "vsx")] | ||
| fn test_vec_add_f64x2_f64x2() { | ||
| let a = vector_double::from(f64x2::from_array([1.0, 2.0])); | ||
| let b = vector_double::from(f64x2::from_array([3.0, 4.0])); | ||
| let expected = vector_double::from(f64x2::from_array([4.0, 6.0])); | ||
|
|
||
| unsafe { | ||
| assert_eq!(f64x2::from(vec_add(a, b)), f64x2::from(expected)); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the only function you'd want to do this for? I'd guess not?
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I do not understand what you mean. Can you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well what about
vec_suband othervec_*methods? Should they not also follow this pattern, or isvec_addspecial somehow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes! I do have a few more other ones to add. I tried to limit this PR to just
vec_addas it is my first patch so I was just trying to get a feel on how these should be done.I have a list of intrinsics that I need to add and the plan was to follow up with sets of 3/4 intrinsics based on type/complexity afterwards. Is there a preferred PR size/breakdown?