Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / complex-math-mixed.c
blob761b62ec9fa7215ab6c3fa67660d6f982ee33e4e
1 // RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
2 // RUN: %clang_cc1 %s -O0 -triple x86_64-unknown-unknown -ast-dump | FileCheck %s --check-prefix=AST
4 // Check that for 'F _Complex + int' (F = real floating-point type), we emit an
5 // implicit cast from 'int' to 'F', but NOT to 'F _Complex' (i.e. that we do
6 // 'F _Complex + F', NOT 'F _Complex + F _Complex'), and likewise for -/*.
8 // AST-NOT: FloatingRealToComplex
10 float _Complex add_float_ci(float _Complex a, int b) {
11 // X86-LABEL: @add_float_ci
12 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
13 // X86: fadd float {{.*}}, [[I]]
14 // X86-NOT: fadd
15 return a + b;
18 float _Complex add_float_ic(int a, float _Complex b) {
19 // X86-LABEL: @add_float_ic
20 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
21 // X86: fadd float [[I]]
22 // X86-NOT: fadd
23 return a + b;
26 float _Complex sub_float_ci(float _Complex a, int b) {
27 // X86-LABEL: @sub_float_ci
28 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
29 // X86: fsub float {{.*}}, [[I]]
30 // X86-NOT: fsub
31 return a - b;
34 float _Complex sub_float_ic(int a, float _Complex b) {
35 // X86-LABEL: @sub_float_ic
36 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
37 // X86: fsub float [[I]]
38 // X86: fneg
39 // X86-NOT: fsub
40 return a - b;
43 float _Complex mul_float_ci(float _Complex a, int b) {
44 // X86-LABEL: @mul_float_ci
45 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
46 // X86: fmul float {{.*}}, [[I]]
47 // X86: fmul float {{.*}}, [[I]]
48 // X86-NOT: fmul
49 return a * b;
52 float _Complex mul_float_ic(int a, float _Complex b) {
53 // X86-LABEL: @mul_float_ic
54 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
55 // X86: fmul float [[I]]
56 // X86: fmul float [[I]]
57 // X86-NOT: fmul
58 return a * b;
61 float _Complex div_float_ci(float _Complex a, int b) {
62 // X86-LABEL: @div_float_ci
63 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
64 // X86: fdiv float {{.*}}, [[I]]
65 // X86: fdiv float {{.*}}, [[I]]
66 // X86-NOT: @__divsc3
67 return a / b;
70 // There is no good way of doing this w/o converting the 'int' to a complex
71 // number, so we expect complex division here.
72 float _Complex div_float_ic(int a, float _Complex b) {
73 // X86-LABEL: @div_float_ic
74 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float
75 // X86: call {{.*}} @__divsc3(float {{.*}} [[I]], float noundef 0.{{0+}}e+00, float {{.*}}, float {{.*}})
76 return a / b;
79 double _Complex add_double_ci(double _Complex a, int b) {
80 // X86-LABEL: @add_double_ci
81 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
82 // X86: fadd double {{.*}}, [[I]]
83 // X86-NOT: fadd
84 return a + b;
87 double _Complex add_double_ic(int a, double _Complex b) {
88 // X86-LABEL: @add_double_ic
89 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
90 // X86: fadd double [[I]]
91 // X86-NOT: fadd
92 return a + b;
95 double _Complex sub_double_ci(double _Complex a, int b) {
96 // X86-LABEL: @sub_double_ci
97 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
98 // X86: fsub double {{.*}}, [[I]]
99 // X86-NOT: fsub
100 return a - b;
103 double _Complex sub_double_ic(int a, double _Complex b) {
104 // X86-LABEL: @sub_double_ic
105 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
106 // X86: fsub double [[I]]
107 // X86: fneg
108 // X86-NOT: fsub
109 return a - b;
112 double _Complex mul_double_ci(double _Complex a, int b) {
113 // X86-LABEL: @mul_double_ci
114 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
115 // X86: fmul double {{.*}}, [[I]]
116 // X86: fmul double {{.*}}, [[I]]
117 // X86-NOT: fmul
118 return a * b;
121 double _Complex mul_double_ic(int a, double _Complex b) {
122 // X86-LABEL: @mul_double_ic
123 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
124 // X86: fmul double [[I]]
125 // X86: fmul double [[I]]
126 // X86-NOT: fmul
127 return a * b;
130 double _Complex div_double_ci(double _Complex a, int b) {
131 // X86-LABEL: @div_double_ci
132 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
133 // X86: fdiv double {{.*}}, [[I]]
134 // X86: fdiv double {{.*}}, [[I]]
135 // X86-NOT: @__divdc3
136 return a / b;
139 // There is no good way of doing this w/o converting the 'int' to a complex
140 // number, so we expect complex division here.
141 double _Complex div_double_ic(int a, double _Complex b) {
142 // X86-LABEL: @div_double_ic
143 // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double
144 // X86: call {{.*}} @__divdc3(double {{.*}} [[I]], double noundef 0.{{0+}}e+00, double {{.*}}, double {{.*}})
145 return a / b;