Skip to content
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

transpile: Add SIMD intrinsic __builtin_ia32_vperm2f128_pd256/_mm256_permute2f128_pd #1129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions c2rust-transpile/src/translator/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ impl<'c> Translation<'c> {
"__builtin_ia32_vec_ext_v2di" => {
self.convert_simd_builtin(ctx, "_mm_extract_epi64", args)
}
"__builtin_ia32_vperm2f128_pd256" => {
self.convert_simd_builtin(ctx, "_mm256_permute2f128_pd", args)
}
"__builtin_ia32_roundps" => self.convert_simd_builtin(ctx, "_mm_round_ps", args),
"__builtin_ia32_roundss" => self.convert_simd_builtin(ctx, "_mm_round_ss", args),
"__builtin_ia32_roundpd" => self.convert_simd_builtin(ctx, "_mm_round_pd", args),
Expand Down
1 change: 1 addition & 0 deletions tests/simd.x86_64/src/test_x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl PartialEq for ShuffleVectors {
b: u128,
c: u128,
d: (u128, u128),
ep: (u128, u128),
e: (u128, u128),
f: u128,
g: u128,
Expand Down
9 changes: 8 additions & 1 deletion tests/simd.x86_64/src/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef struct {
__m128d c;
__m256 d;
__m256d e;
__m256d ep;
__m128i f, g, h, o;
#ifdef __AVX2__
__m256i i, j, k;
Expand Down Expand Up @@ -48,6 +49,7 @@ void zero_init_all(void) {
__m256 b;
__m128d c;
__m128i d;
__m256d ep;
__m256d e;
__m256i f;
#ifdef MMX
Expand All @@ -65,6 +67,7 @@ ShuffleVectors call_all(void) {
__m256d e = _mm256_set_pd(1.1, 2.2, 3.3, 4.4);
__m128i f = _mm_set1_epi8(123);
__m256i g = _mm256_set_epi32(14, 18, 22, 33, -11, -3, 8, 300);
__m256d h = _mm256_set_pd(5.5, 6.6, 7.7, 8.8);

ShuffleVectors sv = {
#ifdef MMX
Expand All @@ -76,6 +79,7 @@ ShuffleVectors call_all(void) {
_mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 2, 1, 0)),
_mm_shuffle_pd(b, b, (1 << 1 | 1 << 0)),
_mm256_shuffle_ps(d, d, _MM_SHUFFLE(1, 2, 2, 1)),
_mm256_permute2f128_pd(e, h, 0x31),
_mm256_shuffle_pd(e, e, (1 << 3 | 1 << 2 | 0 << 1 | 0 << 0)),
_mm_shuffle_epi32(f, _MM_SHUFFLE(1, 0, 0, 1)),
_mm_shufflehi_epi16(f, _MM_SHUFFLE(0, 1, 2, 3)),
Expand Down Expand Up @@ -112,6 +116,7 @@ ShuffleVectors call_all_used(void) {
__m256d ee = _mm256_set_pd(4.4, 3.3, 2.2, 1.1);
__m128i ff = _mm_set1_epi8(13);
__m256i gg = _mm256_set_epi32(-12, 33, 44, 100, -44, 42, -33, -100);
__m256d hh = _mm256_set_pd(5.5, 6.6, 7.7, 8.8);

#ifdef MMX
__m64 a;
Expand All @@ -120,6 +125,7 @@ ShuffleVectors call_all_used(void) {
__m128d c;
__m256 d;
__m256d e;
__m256d ep;
__m128i f, g, h, o;
__m256i i, j, k;
#ifdef MMX
Expand All @@ -140,6 +146,7 @@ ShuffleVectors call_all_used(void) {
b = _mm_shuffle_ps(aa, aa, _MM_SHUFFLE(3, 2, 1, 0));
c = _mm_shuffle_pd(bb, bb, (1 << 1 | 1 << 0));
d = _mm256_shuffle_ps(dd, dd, _MM_SHUFFLE(1, 2, 2, 1));
ep = _mm256_permute2f128_pd(ee, hh, 0x31),
e = _mm256_shuffle_pd(ee, ee, (1 << 3 | 1 << 2 | 0 << 1 | 0 << 0));
f = _mm_shuffle_epi32(ff, _MM_SHUFFLE(1, 0, 0, 1));
g = _mm_shufflehi_epi16(f, _MM_SHUFFLE(0, 1, 2, 3));
Expand Down Expand Up @@ -167,7 +174,7 @@ ShuffleVectors call_all_used(void) {
#ifdef MMX
a,
#endif
b, c, d, e, f, g, h, o,
b, c, d, e, ep, f, g, h, o,

#ifdef __AVX2__
i, j, k,
Expand Down