1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -target-feature +float128 -DTEST_F128 -triple \
4 // RUN: powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s \
5 // RUN: --check-prefix CHECK-F128
7 float crealf(_Complex
float);
8 double creal(_Complex
double);
9 long double creall(_Complex
long double);
11 __float128
crealf128(_Complex __float128
);
12 __float128
foo_f128(_Complex __float128 x
) {
15 // CHECK-F128: define{{.*}} fp128 @foo_f128(fp128 noundef {{[%A-Za-z0-9.]+}}, fp128 noundef {{[%A-Za-z0-9.]+}})
18 float foo_float(_Complex
float x
) {
22 // CHECK: define{{.*}} float @foo_float(float noundef {{[%A-Za-z0-9.]+}}, float noundef {{[%A-Za-z0-9.]+}}) [[NUW:#[0-9]+]] {
24 double foo_double(_Complex
double x
) {
28 // CHECK: define{{.*}} double @foo_double(double noundef {{[%A-Za-z0-9.]+}}, double noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
30 long double foo_long_double(_Complex
long double x
) {
34 // CHECK: define{{.*}} ppc_fp128 @foo_long_double(ppc_fp128 noundef {{[%A-Za-z0-9.]+}}, ppc_fp128 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
36 __ibm128
foo_ibm128(_Complex __ibm128 x
) {
37 // We don't have a suffix for explicit __ibm128 type yet. Use *l instead.
41 // CHECK: define{{.*}} ppc_fp128 @foo_ibm128(ppc_fp128 noundef {{[%A-Za-z0-9.]+}}, ppc_fp128 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
43 int foo_int(_Complex
int x
) {
47 // CHECK: define{{.*}} signext i32 @foo_int(i32 noundef {{[%A-Za-z0-9.]+}}, i32 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
49 short foo_short(_Complex
short x
) {
53 // CHECK: define{{.*}} signext i16 @foo_short(i16 noundef {{[%A-Za-z0-9.]+}}, i16 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
55 signed char foo_char(_Complex
signed char x
) {
59 // CHECK: define{{.*}} signext i8 @foo_char(i8 noundef {{[%A-Za-z0-9.]+}}, i8 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
61 long foo_long(_Complex
long x
) {
65 // CHECK: define{{.*}} i64 @foo_long(i64 noundef {{[%A-Za-z0-9.]+}}, i64 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
67 long long foo_long_long(_Complex
long long x
) {
71 // CHECK: define{{.*}} i64 @foo_long_long(i64 noundef {{[%A-Za-z0-9.]+}}, i64 noundef {{[%A-Za-z0-9.]+}}) [[NUW]] {
73 void bar_float(void) {
74 foo_float(2.0f
- 2.5fi
);
77 // CHECK: define{{.*}} void @bar_float() [[NUW]] {
78 // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = alloca { float, float }, align 4
79 // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }, ptr %[[VAR1]], i32 0, i32 0
80 // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }, ptr %[[VAR1]], i32 0, i32 1
81 // CHECK: store float 2.000000e+00, ptr %[[VAR2]]
82 // CHECK: store float -2.500000e+00, ptr %[[VAR3]]
83 // CHECK: %[[VAR4:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }, ptr %[[VAR1]], i32 0, i32 0
84 // CHECK: %[[VAR5:[A-Za-z0-9.]+]] = load float, ptr %[[VAR4]], align 4
85 // CHECK: %[[VAR6:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }, ptr %[[VAR1]], i32 0, i32 1
86 // CHECK: %[[VAR7:[A-Za-z0-9.]+]] = load float, ptr %[[VAR6]], align 4
87 // CHECK: %{{[A-Za-z0-9.]+}} = call float @foo_float(float noundef %[[VAR5]], float noundef %[[VAR7]])
89 void bar_double(void) {
90 foo_double(2.0 - 2.5i
);
93 // CHECK: define{{.*}} void @bar_double() [[NUW]] {
94 // CHECK: %[[VAR11:[A-Za-z0-9.]+]] = alloca { double, double }, align 8
95 // CHECK: %[[VAR12:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }, ptr %[[VAR11]], i32 0, i32 0
96 // CHECK: %[[VAR13:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }, ptr %[[VAR11]], i32 0, i32 1
97 // CHECK: store double 2.000000e+00, ptr %[[VAR12]]
98 // CHECK: store double -2.500000e+00, ptr %[[VAR13]]
99 // CHECK: %[[VAR14:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }, ptr %[[VAR11]], i32 0, i32 0
100 // CHECK: %[[VAR15:[A-Za-z0-9.]+]] = load double, ptr %[[VAR14]], align 8
101 // CHECK: %[[VAR16:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }, ptr %[[VAR11]], i32 0, i32 1
102 // CHECK: %[[VAR17:[A-Za-z0-9.]+]] = load double, ptr %[[VAR16]], align 8
103 // CHECK: %{{[A-Za-z0-9.]+}} = call double @foo_double(double noundef %[[VAR15]], double noundef %[[VAR17]])
105 void bar_long_double(void) {
106 foo_long_double(2.0L - 2.5Li
);
109 // CHECK: define{{.*}} void @bar_long_double() [[NUW]] {
110 // CHECK: %[[VAR21:[A-Za-z0-9.]+]] = alloca { ppc_fp128, ppc_fp128 }, align 16
111 // CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0
112 // CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1
113 // CHECK: store ppc_fp128 0xM40000000000000000000000000000000, ptr %[[VAR22]]
114 // CHECK: store ppc_fp128 0xMC0040000000000008000000000000000, ptr %[[VAR23]]
115 // CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0
116 // CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR24]], align 16
117 // CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1
118 // CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR26]], align 16
119 // CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_long_double(ppc_fp128 noundef %[[VAR25]], ppc_fp128 noundef %[[VAR27]])
121 void bar_ibm128(void) {
122 foo_ibm128(2.0L - 2.5Li
);
125 // CHECK: define{{.*}} void @bar_ibm128() [[NUW]] {
126 // CHECK: %[[VAR21:[A-Za-z0-9.]+]] = alloca { ppc_fp128, ppc_fp128 }, align 16
127 // CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0
128 // CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1
129 // CHECK: store ppc_fp128 0xM40000000000000000000000000000000, ptr %[[VAR22]]
130 // CHECK: store ppc_fp128 0xMC0040000000000008000000000000000, ptr %[[VAR23]]
131 // CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 0
132 // CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR24]], align 16
133 // CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr %[[VAR21]], i32 0, i32 1
134 // CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128, ptr %[[VAR26]], align 16
135 // CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_ibm128(ppc_fp128 noundef %[[VAR25]], ppc_fp128 noundef %[[VAR27]])
141 // CHECK: define{{.*}} void @bar_int() [[NUW]] {
142 // CHECK: %[[VAR31:[A-Za-z0-9.]+]] = alloca { i32, i32 }, align 4
143 // CHECK: %[[VAR32:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, ptr %[[VAR31]], i32 0, i32 0
144 // CHECK: %[[VAR33:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, ptr %[[VAR31]], i32 0, i32 1
145 // CHECK: store i32 2, ptr %[[VAR32]]
146 // CHECK: store i32 -3, ptr %[[VAR33]]
147 // CHECK: %[[VAR34:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, ptr %[[VAR31]], i32 0, i32 0
148 // CHECK: %[[VAR35:[A-Za-z0-9.]+]] = load i32, ptr %[[VAR34]], align 4
149 // CHECK: %[[VAR36:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, ptr %[[VAR31]], i32 0, i32 1
150 // CHECK: %[[VAR37:[A-Za-z0-9.]+]] = load i32, ptr %[[VAR36]], align 4
151 // CHECK: %{{[A-Za-z0-9.]+}} = call signext i32 @foo_int(i32 noundef %[[VAR35]], i32 noundef %[[VAR37]])
153 void bar_short(void) {
157 // CHECK: define{{.*}} void @bar_short() [[NUW]] {
158 // CHECK: %[[VAR41:[A-Za-z0-9.]+]] = alloca { i16, i16 }, align 2
159 // CHECK: %[[VAR42:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }, ptr %[[VAR41]], i32 0, i32 0
160 // CHECK: %[[VAR43:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }, ptr %[[VAR41]], i32 0, i32 1
161 // CHECK: store i16 2, ptr %[[VAR42]]
162 // CHECK: store i16 -3, ptr %[[VAR43]]
163 // CHECK: %[[VAR44:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }, ptr %[[VAR41]], i32 0, i32 0
164 // CHECK: %[[VAR45:[A-Za-z0-9.]+]] = load i16, ptr %[[VAR44]], align 2
165 // CHECK: %[[VAR46:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }, ptr %[[VAR41]], i32 0, i32 1
166 // CHECK: %[[VAR47:[A-Za-z0-9.]+]] = load i16, ptr %[[VAR46]], align 2
167 // CHECK: %{{[A-Za-z0-9.]+}} = call signext i16 @foo_short(i16 noundef %[[VAR45]], i16 noundef %[[VAR47]])
169 void bar_char(void) {
173 // CHECK: define{{.*}} void @bar_char() [[NUW]] {
174 // CHECK: %[[VAR51:[A-Za-z0-9.]+]] = alloca { i8, i8 }, align 1
175 // CHECK: %[[VAR52:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }, ptr %[[VAR51]], i32 0, i32 0
176 // CHECK: %[[VAR53:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }, ptr %[[VAR51]], i32 0, i32 1
177 // CHECK: store i8 2, ptr %[[VAR52]]
178 // CHECK: store i8 -3, ptr %[[VAR53]]
179 // CHECK: %[[VAR54:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }, ptr %[[VAR51]], i32 0, i32 0
180 // CHECK: %[[VAR55:[A-Za-z0-9.]+]] = load i8, ptr %[[VAR54]], align 1
181 // CHECK: %[[VAR56:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }, ptr %[[VAR51]], i32 0, i32 1
182 // CHECK: %[[VAR57:[A-Za-z0-9.]+]] = load i8, ptr %[[VAR56]], align 1
183 // CHECK: %{{[A-Za-z0-9.]+}} = call signext i8 @foo_char(i8 noundef %[[VAR55]], i8 noundef %[[VAR57]])
185 void bar_long(void) {
189 // CHECK: define{{.*}} void @bar_long() [[NUW]] {
190 // CHECK: %[[VAR61:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8
191 // CHECK: %[[VAR62:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR61]], i32 0, i32 0
192 // CHECK: %[[VAR63:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR61]], i32 0, i32 1
193 // CHECK: store i64 2, ptr %[[VAR62]]
194 // CHECK: store i64 -3, ptr %[[VAR63]]
195 // CHECK: %[[VAR64:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR61]], i32 0, i32 0
196 // CHECK: %[[VAR65:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR64]], align 8
197 // CHECK: %[[VAR66:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR61]], i32 0, i32 1
198 // CHECK: %[[VAR67:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR66]], align 8
199 // CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long(i64 noundef %[[VAR65]], i64 noundef %[[VAR67]])
201 void bar_long_long(void) {
202 foo_long_long(2LL - 3LLi
);
205 // CHECK: define{{.*}} void @bar_long_long() [[NUW]] {
206 // CHECK: %[[VAR71:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8
207 // CHECK: %[[VAR72:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR71]], i32 0, i32 0
208 // CHECK: %[[VAR73:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR71]], i32 0, i32 1
209 // CHECK: store i64 2, ptr %[[VAR72]]
210 // CHECK: store i64 -3, ptr %[[VAR73]]
211 // CHECK: %[[VAR74:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR71]], i32 0, i32 0
212 // CHECK: %[[VAR75:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR74]], align 8
213 // CHECK: %[[VAR76:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }, ptr %[[VAR71]], i32 0, i32 1
214 // CHECK: %[[VAR77:[A-Za-z0-9.]+]] = load i64, ptr %[[VAR76]], align 8
215 // CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long_long(i64 noundef %[[VAR75]], i64 noundef %[[VAR77]])
217 // CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }