summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CGExprComplex.cpp18
-rw-r--r--clang/test/CodeGen/complex-math.c20
2 files changed, 12 insertions, 26 deletions
diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp
index 02fb79ab642..271c9bc5d44 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -584,23 +584,7 @@ ComplexPairTy ComplexExprEmitter::EmitComplexBinOpLibCall(StringRef LibCallName,
llvm::FunctionType *FTy = CGF.CGM.getTypes().GetFunctionType(FuncInfo);
llvm::Constant *Func = CGF.CGM.CreateRuntimeFunction(FTy, LibCallName);
- llvm::Value *ArgVals[] = {Op.LHS.first, Op.LHS.second, Op.RHS.first,
- Op.RHS.second};
- llvm::Value *Result = CGF.EmitRuntimeCall(Func, ArgVals);
-
- llvm::Value *ResR, *ResI;
- if (Result->getType()->isVectorTy()) {
- ResR = CGF.Builder.CreateExtractElement(Result, CGF.Builder.getInt32(0));
- ResI = CGF.Builder.CreateExtractElement(Result, CGF.Builder.getInt32(1));
- } else {
- assert(Result->getType()->isAggregateType() &&
- "Only vector and aggregate libcall returns are supported!");
- unsigned ResRIndices[] = {0};
- ResR = CGF.Builder.CreateExtractValue(Result, ResRIndices);
- unsigned ResIIndices[] = {1};
- ResI = CGF.Builder.CreateExtractValue(Result, ResIIndices);
- }
- return ComplexPairTy(ResR, ResI);
+ return CGF.EmitCall(FuncInfo, Func, ReturnValueSlot(), Args).getComplexVal();
}
// See C11 Annex G.5.1 for the semantics of multiplicative operators on complex
diff --git a/clang/test/CodeGen/complex-math.c b/clang/test/CodeGen/complex-math.c
index a0ac6ecec3b..ca04e8d94d1 100644
--- a/clang/test/CodeGen/complex-math.c
+++ b/clang/test/CodeGen/complex-math.c
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
float _Complex add_float_rr(float a, float b) {
// X86-LABEL: @add_float_rr(
@@ -87,7 +89,7 @@ float _Complex mul_float_rc(float a, float _Complex b) {
float _Complex mul_float_cc(float _Complex a, float _Complex b) {
// X86-LABEL: @mul_float_cc(
// X86-NOT: fmul
- // X86: call <2 x float> @__mulsc3(
+ // X86: call {{.*}} @__mulsc3(
// X86: ret
return a * b;
}
@@ -110,14 +112,14 @@ float _Complex div_float_cr(float _Complex a, float b) {
float _Complex div_float_rc(float a, float _Complex b) {
// X86-LABEL: @div_float_rc(
// X86-NOT: fdiv
- // X86: call <2 x float> @__divsc3(
+ // X86: call {{.*}} @__divsc3(
// X86: ret
return a / b;
}
float _Complex div_float_cc(float _Complex a, float _Complex b) {
// X86-LABEL: @div_float_cc(
// X86-NOT: fdiv
- // X86: call <2 x float> @__divsc3(
+ // X86: call {{.*}} @__divsc3(
// X86: ret
return a / b;
}
@@ -209,7 +211,7 @@ double _Complex mul_double_rc(double a, double _Complex b) {
double _Complex mul_double_cc(double _Complex a, double _Complex b) {
// X86-LABEL: @mul_double_cc(
// X86-NOT: fmul
- // X86: call { double, double } @__muldc3(
+ // X86: call {{.*}} @__muldc3(
// X86: ret
return a * b;
}
@@ -232,14 +234,14 @@ double _Complex div_double_cr(double _Complex a, double b) {
double _Complex div_double_rc(double a, double _Complex b) {
// X86-LABEL: @div_double_rc(
// X86-NOT: fdiv
- // X86: call { double, double } @__divdc3(
+ // X86: call {{.*}} @__divdc3(
// X86: ret
return a / b;
}
double _Complex div_double_cc(double _Complex a, double _Complex b) {
// X86-LABEL: @div_double_cc(
// X86-NOT: fdiv
- // X86: call { double, double } @__divdc3(
+ // X86: call {{.*}} @__divdc3(
// X86: ret
return a / b;
}
@@ -331,7 +333,7 @@ long double _Complex mul_long_double_rc(long double a, long double _Complex b) {
long double _Complex mul_long_double_cc(long double _Complex a, long double _Complex b) {
// X86-LABEL: @mul_long_double_cc(
// X86-NOT: fmul
- // X86: call { x86_fp80, x86_fp80 } @__mulxc3(
+ // X86: call {{.*}} @__mulxc3(
// X86: ret
return a * b;
}
@@ -354,14 +356,14 @@ long double _Complex div_long_double_cr(long double _Complex a, long double b) {
long double _Complex div_long_double_rc(long double a, long double _Complex b) {
// X86-LABEL: @div_long_double_rc(
// X86-NOT: fdiv
- // X86: call { x86_fp80, x86_fp80 } @__divxc3(
+ // X86: call {{.*}} @__divxc3(
// X86: ret
return a / b;
}
long double _Complex div_long_double_cc(long double _Complex a, long double _Complex b) {
// X86-LABEL: @div_long_double_cc(
// X86-NOT: fdiv
- // X86: call { x86_fp80, x86_fp80 } @__divxc3(
+ // X86: call {{.*}} @__divxc3(
// X86: ret
return a / b;
}
OpenPOWER on IntegriCloud