2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GCC と Clang で仕様が違う __builtin_ia32_palignr 関数

Last updated at Posted at 2021-09-15

GCC と Clang にあるビルトイン関数

  __builtin_ia32_palignr
  __builtin_ia32_palignr128

を以下のプログラムで試します。

sample.c
#include <inttypes.h>
#include <stdio.h>
#include <tmmintrin.h>

static void test_palignr()
{
    __v1di a = { 0x0102030405060708ULL };
    a = __builtin_ia32_palignr(a, a, 8);
    printf("%#018"PRIx64"\n", a[0]);
}

static void test_palignr128()
{
    __v2di a = { 0x0102030405060708ULL, 0x090a0b0c0d0e0f10ULL };
    a = __builtin_ia32_palignr128(a, a, 8);
    printf("%#018"PRIx64",%#018"PRIx64"\n", a[0], a[1]);
}

int main()
{
    test_palignr();
    test_palignr128();
    return 0;
}

GCC Version 11.2.0

$ gcc -mssse3 palignr.c && ./a.out 
0x0801020304050607
0x1001020304050607,0x08090a0b0c0d0e0f

Clang Version 12.0.5

$ clang -mssse3 palignr.c && ./a.out 
0x0102030405060708
0x090a0b0c0d0e0f10,0x0102030405060708
2
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?