Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / extend-arg-64.c
blob0749523b9ab3d5f9d7627bf74994be8314effd5c
1 // RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin -fextend-arguments=64 \
2 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
4 // When the option isn't selected, no effect
5 // RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin \
6 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
7 // RUN: --implicit-check-not "ext {{.*}}to i64"
9 // The option isn't supported on x86, no effect
10 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
11 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
12 // RUN: --implicit-check-not "ext {{.*}}to i64"
14 // The option isn't supported on ppc, no effect
15 // RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
16 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
17 // RUN: --implicit-check-not "ext {{.*}}to i64"
19 // The option isn't supported on ppc, no effect
20 // RUN: %clang_cc1 -DD128 -triple powerpc64-ibm-aix-xcoff -fextend-arguments=64 \
21 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
22 // RUN: --implicit-check-not "ext {{.*}}to i64"
25 int vararg(int, ...);
26 void knr();
28 unsigned int u32;
29 int s32;
30 unsigned short u16;
31 short s16;
32 unsigned char u8;
33 signed char s8;
34 long long ll;
35 _BitInt(23) ei23;
36 float ff;
37 double dd;
38 #ifdef D128
39 __int128 i128;
40 #endif
42 int test(void) {
43 // CHECK: define{{.*}} i32 @test{{.*}}
45 // CHECKEXT: [[TAG_u32:%.*]] = load i32, ptr @u32{{.*}}
46 // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
48 // CHECKEXT: [[TAG_s32:%.*]] = load i32, ptr @s32
49 // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
51 // CHECKEXT: [[TAG_u16:%.*]] = load i16, ptr @u16
52 // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
54 // CHECKEXT: [[TAG_s16:%.*]] = load i16, ptr @s16
55 // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
57 // CHECKEXT: [[TAG_u8:%.*]] = load i8, ptr @u8
58 // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
60 // CHECKEXT: [[TAG_s8:%.*]] = load i8, ptr @s8
61 // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
62 // CHECKEXT: call{{.*}} @vararg(i32 noundef %0, i64 noundef [[CONV_u32]], i64 noundef [[CONV_s32]], i64 noundef [[CONV_u16]], i64 noundef [[CONV_s16]], i64 noundef [[CONV_u8]], i64 noundef [[CONV_s8]]
64 int sum = 0;
65 sum = vararg(sum, u32, s32, u16, s16, u8, s8);
66 knr(ll);
67 // CHECKEXT: load i64, ptr @ll
68 // CHECKEXT-NEXT: call void (i64, ...) @knr
70 knr(ei23);
71 // CHECKEXT: load i23, ptr @ei23
72 // CHECKEXT-NEXT: call void (i23, ...) @knr
74 knr(ff);
75 // CHECKEXT: load float
76 // CHECKEXT-NEXT: fpext float {{.*}} to double
77 // CHECKEXT-NEXT: call{{.*}} void (double, ...) @knr
79 knr(dd);
80 // CHECKEXT: load double
81 // CHECKEXT-NEXT: call{{.*}} void (double, ...) @knr
83 #ifdef D128
84 knr(i128);
85 // CHECKEXT: load i128
86 // CHECKEXT: call{{.*}} void (i64, i64, ...) @knr
87 #endif
89 knr(u32, s32, u16, s16, u8, s8);
90 // CHECKEXT: [[TAg_u32:%.*]] = load i32, ptr @u32{{.*}}
91 // CHECKEXT: [[CONv_u32:%.*]] = zext i32 [[TAg_u32]] to i64
93 // CHECKEXT: [[TAg_s32:%.*]] = load i32, ptr @s32
94 // CHECKEXT: [[CONv_s32:%.*]] = sext i32 [[TAg_s32]] to i64
96 // CHECKEXT: [[TAg_u16:%.*]] = load i16, ptr @u16
97 // CHECKEXT: [[CONv_u16:%.*]] = zext i16 [[TAg_u16]] to i64
99 // CHECKEXT: [[TAg_s16:%.*]] = load i16, ptr @s16
100 // CHECKEXT: [[CONv_s16:%.*]] = sext i16 [[TAg_s16]] to i64
102 // CHECKEXT: [[TAg_u8:%.*]] = load i8, ptr @u8
103 // CHECKEXT: [[CONv_u8:%.*]] = zext i8 [[TAg_u8]] to i64
105 // CHECKEXT: [[TAg_s8:%.*]] = load i8, ptr @s8
106 // CHECKEXT: [[CONv_s8:%.*]] = sext i8 [[TAg_s8]] to i64
107 // CHECKEXT: call{{.*}} void (i64, i64, i64, i64, i64, i64, ...) @knr
108 return sum;