xref: /llvm-project/clang/test/CodeGen/PowerPC/ppc-pmmintrin.c (revision de7c0068329d78027df7b7184d72646c1ca9f2bd)
1 // REQUIRES: powerpc-registered-target
2 
3 // RUN: %clang -S -emit-llvm -target powerpc64-gnu-linux -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
4 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
5 // RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
6 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
7 
8 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
9 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
10 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
11 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
12 
13 // RUN: %clang -S -emit-llvm -target powerpc64-ibm-aix -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
14 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
15 
16 // RUN: %clang -x c++ -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
17 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -fsyntax-only
18 
19 #include <pmmintrin.h>
20 
21 __m128d resd, md1, md2;
22 __m128 res, m1, m2;
23 __m128i resi, mi;
24 double *d;
25 
26 void __attribute__((noinline))
test_pmmintrin()27 test_pmmintrin() {
28   resd = _mm_addsub_pd(md1, md2);
29   res = _mm_addsub_ps(m1, m2);
30   resd = _mm_hadd_pd(md1, md2);
31   res = _mm_hadd_ps(m1, m2);
32   resd = _mm_hsub_pd(md1, md2);
33   res = _mm_hsub_ps(m1, m2);
34   resi = _mm_lddqu_si128(&mi);
35   resd = _mm_loaddup_pd(d);
36   resd = _mm_movedup_pd(md1);
37   res = _mm_movehdup_ps(m1);
38   res = _mm_moveldup_ps(m1);
39 }
40 
41 // CHECK-LABEL: define available_externally <2 x double> @_mm_addsub_pd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, <2 x double> noundef %{{[0-9a-zA-Z_.]+}})
42 // CHECK: call <2 x double> @vec_xor(double vector[2], double vector[2])(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, <2 x double> noundef <double -0.000000e+00, double 0.000000e+00>)
43 // CHECK: call <2 x double> @vec_add(double vector[2], double vector[2])
44 
45 // CHECK-LABEL: define available_externally <4 x float> @_mm_addsub_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, <4 x float> noundef %{{[0-9a-zA-Z_.]+}})
46 // CHECK: call <4 x float> @vec_xor(float vector[4], float vector[4])(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, <4 x float> noundef <float -0.000000e+00, float 0.000000e+00, float -0.000000e+00, float 0.000000e+00>)
47 // CHECK: call <4 x float> @vec_add(float vector[4], float vector[4])
48 
49 // CHECK-LABEL: define available_externally <2 x double> @_mm_hadd_pd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, <2 x double> noundef %{{[0-9a-zA-Z_.]+}})
50 // CHECK: %[[CALL:[0-9a-zA-Z_.]+]] = call <2 x double> @vec_mergeh(double vector[2], double vector[2])
51 // CHECK: %[[CALL1:[0-9a-zA-Z_.]+]] = call <2 x double> @vec_mergel(double vector[2], double vector[2])
52 // CHECK: %[[CALL2:[0-9a-zA-Z_.]+]] = call <2 x double> @vec_add(double vector[2], double vector[2])(<2 x double> noundef %[[CALL]], <2 x double> noundef %[[CALL1]])
53 
54 // CHECK-LABEL: define available_externally <4 x float> @_mm_hadd_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, <4 x float> noundef %{{[0-9a-zA-Z_.]+}})
55 // CHECK: store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 8, i8 9, i8 10, i8 11, i8 16, i8 17, i8 18, i8 19, i8 24, i8 25, i8 26, i8 27>, ptr %{{[0-9a-zA-Z_.]+}}, align 16
56 // CHECK: store <16 x i8> <i8 4, i8 5, i8 6, i8 7, i8 12, i8 13, i8 14, i8 15, i8 20, i8 21, i8 22, i8 23, i8 28, i8 29, i8 30, i8 31>, ptr %{{[0-9a-zA-Z_.]+}}, align 16
57 // CHECK: %[[CALL:[0-9a-zA-Z_.]+]] = call <4 x float> @vec_perm(float vector[4], float vector[4], unsigned char vector[16])
58 // CHECK: %[[CALL1:[0-9a-zA-Z_.]+]] = call <4 x float> @vec_perm(float vector[4], float vector[4], unsigned char vector[16])
59 // CHECK: %[[CALL2:[0-9a-zA-Z_.]+]] = call <4 x float> @vec_add(float vector[4], float vector[4])(<4 x float> noundef %[[CALL]], <4 x float> noundef %[[CALL1]])
60 
61 // CHECK-LABEL: define available_externally <2 x double> @_mm_hsub_pd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, <2 x double> noundef %{{[0-9a-zA-Z_.]+}})
62 // CHECK: %[[CALL:[0-9a-zA-Z_.]+]] = call <2 x double> @vec_mergeh(double vector[2], double vector[2])
63 // CHECK: %[[CALL1:[0-9a-zA-Z_.]+]] = call <2 x double> @vec_mergel(double vector[2], double vector[2])
64 // CHECK: %[[CALL2:[0-9a-zA-Z_.]+]] = call <2 x double> @vec_sub(double vector[2], double vector[2])(<2 x double> noundef %[[CALL]], <2 x double> noundef %[[CALL1]])
65 
66 // CHECK-LABEL: define available_externally <4 x float> @_mm_hsub_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, <4 x float> noundef %{{[0-9a-zA-Z_.]+}})
67 // CHECK: store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 8, i8 9, i8 10, i8 11, i8 16, i8 17, i8 18, i8 19, i8 24, i8 25, i8 26, i8 27>, ptr %{{[0-9a-zA-Z_.]+}}, align 16
68 // CHECK: store <16 x i8> <i8 4, i8 5, i8 6, i8 7, i8 12, i8 13, i8 14, i8 15, i8 20, i8 21, i8 22, i8 23, i8 28, i8 29, i8 30, i8 31>, ptr %{{[0-9a-zA-Z_.]+}}, align 16
69 // CHECK: %[[CALL:[0-9a-zA-Z_.]+]] = call <4 x float> @vec_perm(float vector[4], float vector[4], unsigned char vector[16])
70 // CHECK: %[[CALL1:[0-9a-zA-Z_.]+]] = call <4 x float> @vec_perm(float vector[4], float vector[4], unsigned char vector[16])
71 // CHECK: %[[CALL2:[0-9a-zA-Z_.]+]] = call <4 x float> @vec_sub(float vector[4], float vector[4])(<4 x float> noundef %[[CALL]], <4 x float> noundef %[[CALL1]])
72 
73 // CHECK-LABEL: define available_externally <2 x i64> @_mm_lddqu_si128(ptr noundef %{{[0-9a-zA-Z_.]+}})
74 // CHECK: call <4 x i32> @vec_vsx_ld(int, int const*)(i32 noundef signext 0, ptr noundef %{{[0-9a-zA-Z_.]+}})
75 
76 // CHECK-LABEL: define available_externally <2 x double> @_mm_loaddup_pd(ptr noundef %{{[0-9a-zA-Z_.]+}})
77 // CHECK: call <2 x double> @vec_splats(double)
78 
79 // CHECK-LABEL: define available_externally <2 x double> @_mm_movedup_pd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}})
80 // CHECK: call <2 x double> @_mm_shuffle_pd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, <2 x double> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext 0)
81 
82 // CHECK-LABEL: define available_externally <4 x float> @_mm_movehdup_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}})
83 // CHECK: call <4 x i32> @vec_mergeo(unsigned int vector[4], unsigned int vector[4])
84 
85 // CHECK-LABEL: define available_externally <4 x float> @_mm_moveldup_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}})
86 // CHECK: call <4 x i32> @vec_mergee(unsigned int vector[4], unsigned int vector[4])
87