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]]
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]]
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]]
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]]
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]]
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]]
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]]
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 {{.*}})
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]]
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]]
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]]
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]]
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]]
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]]
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
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 {{.*}})