aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarat Dukhan <maratek@gmail.com>2017-04-15 05:51:43 -0400
committerMarat Dukhan <maratek@gmail.com>2017-04-15 05:51:43 -0400
commit0b26a3fb98dd6af7e1f4e0796c56df6b32b1c016 (patch)
tree54c115c662fa3a48e3f92911effeee03698828aa
parent6d9ce9d5a08737a424baecc7587e487396b9729a (diff)
downloadpsimd-0b26a3fb98dd6af7e1f4e0796c56df6b32b1c016.tar.gz
Splat vector lane
-rw-r--r--include/psimd.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/psimd.h b/include/psimd.h
index 29f3459..9396528 100644
--- a/include/psimd.h
+++ b/include/psimd.h
@@ -743,6 +743,41 @@
#endif
}
+ /* Broadcast vector element */
+ #if defined(__clang__)
+ PSIMD_INTRINSIC psimd_f32 psimd_splat0_f32(psimd_f32 v) {
+ return __builtin_shufflevector(v, v, 0, 0, 0, 0);
+ }
+
+ PSIMD_INTRINSIC psimd_f32 psimd_splat1_f32(psimd_f32 v) {
+ return __builtin_shufflevector(v, v, 1, 1, 1, 1);
+ }
+
+ PSIMD_INTRINSIC psimd_f32 psimd_splat2_f32(psimd_f32 v) {
+ return __builtin_shufflevector(v, v, 2, 2, 2, 2);
+ }
+
+ PSIMD_INTRINSIC psimd_f32 psimd_splat3_f32(psimd_f32 v) {
+ return __builtin_shufflevector(v, v, 3, 3, 3, 3);
+ }
+ #else
+ PSIMD_INTRINSIC psimd_f32 psimd_splat0_f32(psimd_f32 v) {
+ return __builtin_shuffle(v, (psimd_s32) { 0, 0, 0, 0 });
+ }
+
+ PSIMD_INTRINSIC psimd_f32 psimd_splat1_f32(psimd_f32 v) {
+ return __builtin_shuffle(v, (psimd_s32) { 1, 1, 1, 1 });
+ }
+
+ PSIMD_INTRINSIC psimd_f32 psimd_splat2_f32(psimd_f32 v) {
+ return __builtin_shuffle(v, (psimd_s32) { 2, 2, 2, 2 });
+ }
+
+ PSIMD_INTRINSIC psimd_f32 psimd_splat3_f32(psimd_f32 v) {
+ return __builtin_shuffle(v, (psimd_s32) { 3, 3, 3, 3 });
+ }
+ #endif
+
/* Reversal of vector elements */
#if defined(__clang__)
PSIMD_INTRINSIC psimd_s8 psimd_reverse_s8(psimd_s8 v) {