1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc float crealf(_Complex float);
4*f4a2713aSLionel Sambuc double creal(_Complex double);
5*f4a2713aSLionel Sambuc long double creall(_Complex long double);
6*f4a2713aSLionel Sambuc
foo_float(_Complex float x)7*f4a2713aSLionel Sambuc float foo_float(_Complex float x) {
8*f4a2713aSLionel Sambuc return crealf(x);
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc // CHECK: define float @foo_float(float {{[%A-Za-z0-9.]+}}, float {{[%A-Za-z0-9.]+}}) [[NUW:#[0-9]+]] {
12*f4a2713aSLionel Sambuc
foo_double(_Complex double x)13*f4a2713aSLionel Sambuc double foo_double(_Complex double x) {
14*f4a2713aSLionel Sambuc return creal(x);
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc // CHECK: define double @foo_double(double {{[%A-Za-z0-9.]+}}, double {{[%A-Za-z0-9.]+}}) [[NUW]] {
18*f4a2713aSLionel Sambuc
foo_long_double(_Complex long double x)19*f4a2713aSLionel Sambuc long double foo_long_double(_Complex long double x) {
20*f4a2713aSLionel Sambuc return creall(x);
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc // CHECK: define ppc_fp128 @foo_long_double(ppc_fp128 {{[%A-Za-z0-9.]+}}, ppc_fp128 {{[%A-Za-z0-9.]+}}) [[NUW]] {
24*f4a2713aSLionel Sambuc
foo_int(_Complex int x)25*f4a2713aSLionel Sambuc int foo_int(_Complex int x) {
26*f4a2713aSLionel Sambuc return __real__ x;
27*f4a2713aSLionel Sambuc }
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc // CHECK: define signext i32 @foo_int(i32 {{[%A-Za-z0-9.]+}}, i32 {{[%A-Za-z0-9.]+}}) [[NUW]] {
30*f4a2713aSLionel Sambuc
foo_short(_Complex short x)31*f4a2713aSLionel Sambuc short foo_short(_Complex short x) {
32*f4a2713aSLionel Sambuc return __real__ x;
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc // CHECK: define signext i16 @foo_short(i16 {{[%A-Za-z0-9.]+}}, i16 {{[%A-Za-z0-9.]+}}) [[NUW]] {
36*f4a2713aSLionel Sambuc
foo_char(_Complex signed char x)37*f4a2713aSLionel Sambuc signed char foo_char(_Complex signed char x) {
38*f4a2713aSLionel Sambuc return __real__ x;
39*f4a2713aSLionel Sambuc }
40*f4a2713aSLionel Sambuc
41*f4a2713aSLionel Sambuc // CHECK: define signext i8 @foo_char(i8 {{[%A-Za-z0-9.]+}}, i8 {{[%A-Za-z0-9.]+}}) [[NUW]] {
42*f4a2713aSLionel Sambuc
foo_long(_Complex long x)43*f4a2713aSLionel Sambuc long foo_long(_Complex long x) {
44*f4a2713aSLionel Sambuc return __real__ x;
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambuc // CHECK: define i64 @foo_long(i64 {{[%A-Za-z0-9.]+}}, i64 {{[%A-Za-z0-9.]+}}) [[NUW]] {
48*f4a2713aSLionel Sambuc
foo_long_long(_Complex long long x)49*f4a2713aSLionel Sambuc long long foo_long_long(_Complex long long x) {
50*f4a2713aSLionel Sambuc return __real__ x;
51*f4a2713aSLionel Sambuc }
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel Sambuc // CHECK: define i64 @foo_long_long(i64 {{[%A-Za-z0-9.]+}}, i64 {{[%A-Za-z0-9.]+}}) [[NUW]] {
54*f4a2713aSLionel Sambuc
bar_float(void)55*f4a2713aSLionel Sambuc void bar_float(void) {
56*f4a2713aSLionel Sambuc foo_float(2.0f - 2.5fi);
57*f4a2713aSLionel Sambuc }
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc // CHECK: define void @bar_float() [[NUW]] {
60*f4a2713aSLionel Sambuc // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = alloca { float, float }, align 4
61*f4a2713aSLionel Sambuc // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }* %[[VAR1]], i32 0, i32 0
62*f4a2713aSLionel Sambuc // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }* %[[VAR1]], i32 0, i32 1
63*f4a2713aSLionel Sambuc // CHECK: store float 2.000000e+00, float* %[[VAR2]]
64*f4a2713aSLionel Sambuc // CHECK: store float -2.500000e+00, float* %[[VAR3]]
65*f4a2713aSLionel Sambuc // CHECK: %[[VAR4:[A-Za-z0-9.]+]] = getelementptr { float, float }* %[[VAR1]], i32 0, i32 0
66*f4a2713aSLionel Sambuc // CHECK: %[[VAR5:[A-Za-z0-9.]+]] = load float* %[[VAR4]], align 1
67*f4a2713aSLionel Sambuc // CHECK: %[[VAR6:[A-Za-z0-9.]+]] = getelementptr { float, float }* %[[VAR1]], i32 0, i32 1
68*f4a2713aSLionel Sambuc // CHECK: %[[VAR7:[A-Za-z0-9.]+]] = load float* %[[VAR6]], align 1
69*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call float @foo_float(float %[[VAR5]], float %[[VAR7]])
70*f4a2713aSLionel Sambuc
bar_double(void)71*f4a2713aSLionel Sambuc void bar_double(void) {
72*f4a2713aSLionel Sambuc foo_double(2.0 - 2.5i);
73*f4a2713aSLionel Sambuc }
74*f4a2713aSLionel Sambuc
75*f4a2713aSLionel Sambuc // CHECK: define void @bar_double() [[NUW]] {
76*f4a2713aSLionel Sambuc // CHECK: %[[VAR11:[A-Za-z0-9.]+]] = alloca { double, double }, align 8
77*f4a2713aSLionel Sambuc // CHECK: %[[VAR12:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }* %[[VAR11]], i32 0, i32 0
78*f4a2713aSLionel Sambuc // CHECK: %[[VAR13:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }* %[[VAR11]], i32 0, i32 1
79*f4a2713aSLionel Sambuc // CHECK: store double 2.000000e+00, double* %[[VAR12]]
80*f4a2713aSLionel Sambuc // CHECK: store double -2.500000e+00, double* %[[VAR13]]
81*f4a2713aSLionel Sambuc // CHECK: %[[VAR14:[A-Za-z0-9.]+]] = getelementptr { double, double }* %[[VAR11]], i32 0, i32 0
82*f4a2713aSLionel Sambuc // CHECK: %[[VAR15:[A-Za-z0-9.]+]] = load double* %[[VAR14]], align 1
83*f4a2713aSLionel Sambuc // CHECK: %[[VAR16:[A-Za-z0-9.]+]] = getelementptr { double, double }* %[[VAR11]], i32 0, i32 1
84*f4a2713aSLionel Sambuc // CHECK: %[[VAR17:[A-Za-z0-9.]+]] = load double* %[[VAR16]], align 1
85*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call double @foo_double(double %[[VAR15]], double %[[VAR17]])
86*f4a2713aSLionel Sambuc
bar_long_double(void)87*f4a2713aSLionel Sambuc void bar_long_double(void) {
88*f4a2713aSLionel Sambuc foo_long_double(2.0L - 2.5Li);
89*f4a2713aSLionel Sambuc }
90*f4a2713aSLionel Sambuc
91*f4a2713aSLionel Sambuc // CHECK: define void @bar_long_double() [[NUW]] {
92*f4a2713aSLionel Sambuc // CHECK: %[[VAR21:[A-Za-z0-9.]+]] = alloca { ppc_fp128, ppc_fp128 }, align 16
93*f4a2713aSLionel Sambuc // CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0
94*f4a2713aSLionel Sambuc // CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1
95*f4a2713aSLionel Sambuc // CHECK: store ppc_fp128 0xM40000000000000000000000000000000, ppc_fp128* %[[VAR22]]
96*f4a2713aSLionel Sambuc // CHECK: store ppc_fp128 0xMC0040000000000000000000000000000, ppc_fp128* %[[VAR23]]
97*f4a2713aSLionel Sambuc // CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0
98*f4a2713aSLionel Sambuc // CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128* %[[VAR24]], align 1
99*f4a2713aSLionel Sambuc // CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1
100*f4a2713aSLionel Sambuc // CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128* %[[VAR26]], align 1
101*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_long_double(ppc_fp128 %[[VAR25]], ppc_fp128 %[[VAR27]])
102*f4a2713aSLionel Sambuc
bar_int(void)103*f4a2713aSLionel Sambuc void bar_int(void) {
104*f4a2713aSLionel Sambuc foo_int(2 - 3i);
105*f4a2713aSLionel Sambuc }
106*f4a2713aSLionel Sambuc
107*f4a2713aSLionel Sambuc // CHECK: define void @bar_int() [[NUW]] {
108*f4a2713aSLionel Sambuc // CHECK: %[[VAR31:[A-Za-z0-9.]+]] = alloca { i32, i32 }, align 4
109*f4a2713aSLionel Sambuc // CHECK: %[[VAR32:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }* %[[VAR31]], i32 0, i32 0
110*f4a2713aSLionel Sambuc // CHECK: %[[VAR33:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }* %[[VAR31]], i32 0, i32 1
111*f4a2713aSLionel Sambuc // CHECK: store i32 2, i32* %[[VAR32]]
112*f4a2713aSLionel Sambuc // CHECK: store i32 -3, i32* %[[VAR33]]
113*f4a2713aSLionel Sambuc // CHECK: %[[VAR34:[A-Za-z0-9.]+]] = getelementptr { i32, i32 }* %[[VAR31]], i32 0, i32 0
114*f4a2713aSLionel Sambuc // CHECK: %[[VAR35:[A-Za-z0-9.]+]] = load i32* %[[VAR34]], align 1
115*f4a2713aSLionel Sambuc // CHECK: %[[VAR36:[A-Za-z0-9.]+]] = getelementptr { i32, i32 }* %[[VAR31]], i32 0, i32 1
116*f4a2713aSLionel Sambuc // CHECK: %[[VAR37:[A-Za-z0-9.]+]] = load i32* %[[VAR36]], align 1
117*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call signext i32 @foo_int(i32 %[[VAR35]], i32 %[[VAR37]])
118*f4a2713aSLionel Sambuc
bar_short(void)119*f4a2713aSLionel Sambuc void bar_short(void) {
120*f4a2713aSLionel Sambuc foo_short(2 - 3i);
121*f4a2713aSLionel Sambuc }
122*f4a2713aSLionel Sambuc
123*f4a2713aSLionel Sambuc // CHECK: define void @bar_short() [[NUW]] {
124*f4a2713aSLionel Sambuc // CHECK: %[[VAR41:[A-Za-z0-9.]+]] = alloca { i16, i16 }, align 2
125*f4a2713aSLionel Sambuc // CHECK: %[[VAR42:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }* %[[VAR41]], i32 0, i32 0
126*f4a2713aSLionel Sambuc // CHECK: %[[VAR43:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }* %[[VAR41]], i32 0, i32 1
127*f4a2713aSLionel Sambuc // CHECK: store i16 2, i16* %[[VAR42]]
128*f4a2713aSLionel Sambuc // CHECK: store i16 -3, i16* %[[VAR43]]
129*f4a2713aSLionel Sambuc // CHECK: %[[VAR44:[A-Za-z0-9.]+]] = getelementptr { i16, i16 }* %[[VAR41]], i32 0, i32 0
130*f4a2713aSLionel Sambuc // CHECK: %[[VAR45:[A-Za-z0-9.]+]] = load i16* %[[VAR44]], align 1
131*f4a2713aSLionel Sambuc // CHECK: %[[VAR46:[A-Za-z0-9.]+]] = getelementptr { i16, i16 }* %[[VAR41]], i32 0, i32 1
132*f4a2713aSLionel Sambuc // CHECK: %[[VAR47:[A-Za-z0-9.]+]] = load i16* %[[VAR46]], align 1
133*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call signext i16 @foo_short(i16 %[[VAR45]], i16 %[[VAR47]])
134*f4a2713aSLionel Sambuc
bar_char(void)135*f4a2713aSLionel Sambuc void bar_char(void) {
136*f4a2713aSLionel Sambuc foo_char(2 - 3i);
137*f4a2713aSLionel Sambuc }
138*f4a2713aSLionel Sambuc
139*f4a2713aSLionel Sambuc // CHECK: define void @bar_char() [[NUW]] {
140*f4a2713aSLionel Sambuc // CHECK: %[[VAR51:[A-Za-z0-9.]+]] = alloca { i8, i8 }, align 1
141*f4a2713aSLionel Sambuc // CHECK: %[[VAR52:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }* %[[VAR51]], i32 0, i32 0
142*f4a2713aSLionel Sambuc // CHECK: %[[VAR53:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }* %[[VAR51]], i32 0, i32 1
143*f4a2713aSLionel Sambuc // CHECK: store i8 2, i8* %[[VAR52]]
144*f4a2713aSLionel Sambuc // CHECK: store i8 -3, i8* %[[VAR53]]
145*f4a2713aSLionel Sambuc // CHECK: %[[VAR54:[A-Za-z0-9.]+]] = getelementptr { i8, i8 }* %[[VAR51]], i32 0, i32 0
146*f4a2713aSLionel Sambuc // CHECK: %[[VAR55:[A-Za-z0-9.]+]] = load i8* %[[VAR54]], align 1
147*f4a2713aSLionel Sambuc // CHECK: %[[VAR56:[A-Za-z0-9.]+]] = getelementptr { i8, i8 }* %[[VAR51]], i32 0, i32 1
148*f4a2713aSLionel Sambuc // CHECK: %[[VAR57:[A-Za-z0-9.]+]] = load i8* %[[VAR56]], align 1
149*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call signext i8 @foo_char(i8 %[[VAR55]], i8 %[[VAR57]])
150*f4a2713aSLionel Sambuc
bar_long(void)151*f4a2713aSLionel Sambuc void bar_long(void) {
152*f4a2713aSLionel Sambuc foo_long(2L - 3Li);
153*f4a2713aSLionel Sambuc }
154*f4a2713aSLionel Sambuc
155*f4a2713aSLionel Sambuc // CHECK: define void @bar_long() [[NUW]] {
156*f4a2713aSLionel Sambuc // CHECK: %[[VAR61:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8
157*f4a2713aSLionel Sambuc // CHECK: %[[VAR62:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR61]], i32 0, i32 0
158*f4a2713aSLionel Sambuc // CHECK: %[[VAR63:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR61]], i32 0, i32 1
159*f4a2713aSLionel Sambuc // CHECK: store i64 2, i64* %[[VAR62]]
160*f4a2713aSLionel Sambuc // CHECK: store i64 -3, i64* %[[VAR63]]
161*f4a2713aSLionel Sambuc // CHECK: %[[VAR64:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR61]], i32 0, i32 0
162*f4a2713aSLionel Sambuc // CHECK: %[[VAR65:[A-Za-z0-9.]+]] = load i64* %[[VAR64]], align 1
163*f4a2713aSLionel Sambuc // CHECK: %[[VAR66:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR61]], i32 0, i32 1
164*f4a2713aSLionel Sambuc // CHECK: %[[VAR67:[A-Za-z0-9.]+]] = load i64* %[[VAR66]], align 1
165*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long(i64 %[[VAR65]], i64 %[[VAR67]])
166*f4a2713aSLionel Sambuc
bar_long_long(void)167*f4a2713aSLionel Sambuc void bar_long_long(void) {
168*f4a2713aSLionel Sambuc foo_long_long(2LL - 3LLi);
169*f4a2713aSLionel Sambuc }
170*f4a2713aSLionel Sambuc
171*f4a2713aSLionel Sambuc // CHECK: define void @bar_long_long() [[NUW]] {
172*f4a2713aSLionel Sambuc // CHECK: %[[VAR71:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8
173*f4a2713aSLionel Sambuc // CHECK: %[[VAR72:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR71]], i32 0, i32 0
174*f4a2713aSLionel Sambuc // CHECK: %[[VAR73:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR71]], i32 0, i32 1
175*f4a2713aSLionel Sambuc // CHECK: store i64 2, i64* %[[VAR72]]
176*f4a2713aSLionel Sambuc // CHECK: store i64 -3, i64* %[[VAR73]]
177*f4a2713aSLionel Sambuc // CHECK: %[[VAR74:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR71]], i32 0, i32 0
178*f4a2713aSLionel Sambuc // CHECK: %[[VAR75:[A-Za-z0-9.]+]] = load i64* %[[VAR74]], align 1
179*f4a2713aSLionel Sambuc // CHECK: %[[VAR76:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR71]], i32 0, i32 1
180*f4a2713aSLionel Sambuc // CHECK: %[[VAR77:[A-Za-z0-9.]+]] = load i64* %[[VAR76]], align 1
181*f4a2713aSLionel Sambuc // CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long_long(i64 %[[VAR75]], i64 %[[VAR77]])
182*f4a2713aSLionel Sambuc
183*f4a2713aSLionel Sambuc // CHECK: attributes [[NUW]] = { nounwind{{.*}} }
184