Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / PowerPC / builtins-ppc.c
blobc13edf44cdcbd2a5b2aed5298225d1a004ec5a44
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm %s -o - \
3 // RUN: | FileCheck %s
4 // RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm %s -o - \
5 // RUN: -target-cpu pwr9 | FileCheck %s --check-prefixes=P9,CHECK
7 void test_eh_return_data_regno()
9 volatile int res;
10 res = __builtin_eh_return_data_regno(0); // CHECK: store volatile i32 3
11 res = __builtin_eh_return_data_regno(1); // CHECK: store volatile i32 4
14 // CHECK-LABEL: define{{.*}} i64 @test_builtin_ppc_get_timebase
15 long long test_builtin_ppc_get_timebase() {
16 // CHECK: call i64 @llvm.readcyclecounter()
17 return __builtin_ppc_get_timebase();
20 void test_builtin_ppc_setrnd() {
21 volatile double res;
22 volatile int x = 100;
24 // CHECK: call double @llvm.ppc.setrnd(i32 2)
25 res = __builtin_setrnd(2);
27 // CHECK: call double @llvm.ppc.setrnd(i32 100)
28 res = __builtin_setrnd(100);
30 // CHECK: call double @llvm.ppc.setrnd(i32 %2)
31 res = __builtin_setrnd(x);
33 // CHECK: call double @llvm.ppc.setrnd(i32 %4)
34 res = __builtin_ppc_set_fpscr_rn(x);
37 void test_builtin_ppc_flm() {
38 volatile double res;
39 // CHECK: call double @llvm.ppc.readflm()
40 res = __builtin_readflm();
42 // CHECK: call double @llvm.ppc.readflm()
43 res = __builtin_ppc_mffs();
45 // CHECK: call double @llvm.ppc.setflm(double %2)
46 res = __builtin_setflm(res);
48 #ifdef _ARCH_PWR9
49 // P9: call double @llvm.ppc.mffsl()
50 res = __builtin_ppc_mffsl();
51 #endif
54 double test_builtin_unpack_ldbl(long double x) {
55 // CHECK: call double @llvm.ppc.unpack.longdouble(ppc_fp128 %0, i32 1)
56 return __builtin_unpack_longdouble(x, 1);
59 long double test_builtin_pack_ldbl(double x, double y) {
60 // CHECK: call ppc_fp128 @llvm.ppc.pack.longdouble(double %0, double %1)
61 return __builtin_pack_longdouble(x, y);
64 void test_builtin_ppc_maxminfe(long double a, long double b, long double c,
65 long double d) {
66 volatile long double res;
67 // CHECK: call ppc_fp128 (ppc_fp128, ppc_fp128, ppc_fp128, ...) @llvm.ppc.maxfe(ppc_fp128 %0, ppc_fp128 %1, ppc_fp128 %2, ppc_fp128 %3)
68 res = __builtin_ppc_maxfe(a, b, c, d);
70 // CHECK: call ppc_fp128 (ppc_fp128, ppc_fp128, ppc_fp128, ...) @llvm.ppc.minfe(ppc_fp128 %5, ppc_fp128 %6, ppc_fp128 %7, ppc_fp128 %8)
71 res = __builtin_ppc_minfe(a, b, c, d);
74 void test_builtin_ppc_maxminfl(double a, double b, double c, double d) {
75 volatile double res;
76 // CHECK: call double (double, double, double, ...) @llvm.ppc.maxfl(double %0, double %1, double %2, double %3)
77 res = __builtin_ppc_maxfl(a, b, c, d);
79 // CHECK: call double (double, double, double, ...) @llvm.ppc.minfl(double %5, double %6, double %7, double %8)
80 res = __builtin_ppc_minfl(a, b, c, d);
83 void test_builtin_ppc_maxminfs(float a, float b, float c, float d) {
84 volatile float res;
85 // CHECK: call float (float, float, float, ...) @llvm.ppc.maxfs(float %0, float %1, float %2, float %3)
86 res = __builtin_ppc_maxfs(a, b, c, d);
88 // CHECK: call float (float, float, float, ...) @llvm.ppc.minfs(float %5, float %6, float %7, float %8)
89 res = __builtin_ppc_minfs(a, b, c, d);