Author: Craig Topper Date: 2019-12-31T10:41:00-08:00 New Revision: 5e5a1d27909626169c15b8f63e10d22fcbdf88d9
URL: https://github.com/llvm/llvm-project/commit/5e5a1d27909626169c15b8f63e10d22fcbdf88d9 DIFF: https://github.com/llvm/llvm-project/commit/5e5a1d27909626169c15b8f63e10d22fcbdf88d9.diff LOG: [CodeGen] Emit conj/conjf/confjl libcalls as fneg instructions if possible. We already recognize the __builtin versions of these, might as well recognize the libcall version. Differential Revision: https://reviews.llvm.org/D72028 Added: clang/test/CodeGen/complex-libcalls-2.c Modified: clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/complex-libcalls.c Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index fe0607bbd027..be02004bf54b 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -1938,7 +1938,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, } case Builtin::BI__builtin_conj: case Builtin::BI__builtin_conjf: - case Builtin::BI__builtin_conjl: { + case Builtin::BI__builtin_conjl: + case Builtin::BIconj: + case Builtin::BIconjf: + case Builtin::BIconjl: { ComplexPairTy ComplexVal = EmitComplexExpr(E->getArg(0)); Value *Real = ComplexVal.first; Value *Imag = ComplexVal.second; diff --git a/clang/test/CodeGen/complex-libcalls-2.c b/clang/test/CodeGen/complex-libcalls-2.c new file mode 100644 index 000000000000..1938cf460c91 --- /dev/null +++ b/clang/test/CodeGen/complex-libcalls-2.c @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s + +float _Complex test_conjf(float _Complex x) { +// CHECK-LABEL: @test_conjf( +// CHECK: fneg float %x.imag + return conjf(x); +} + +double _Complex test_conj(double _Complex x) { +// CHECK-LABEL: @test_conj( +// CHECK: fneg double %x.imag + return conj(x); +} + +long double _Complex test_conjl(long double _Complex x) { +// CHECK-LABEL: @test_conjl( +// CHECK: fneg x86_fp80 %x.imag + return conjl(x); +} diff --git a/clang/test/CodeGen/complex-libcalls.c b/clang/test/CodeGen/complex-libcalls.c index 5690119e1013..248041788293 100644 --- a/clang/test/CodeGen/complex-libcalls.c +++ b/clang/test/CodeGen/complex-libcalls.c @@ -112,12 +112,10 @@ void foo(float f) { conj(f); conjf(f); conjl(f); -// NO__ERRNO: declare { double, double } @conj(double, double) [[READNONE:#[0-9]+]] -// NO__ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]] -// NO__ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]] -// HAS_ERRNO: declare { double, double } @conj(double, double) [[READNONE:#[0-9]+]] -// HAS_ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]] -// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]] +// NO__ERRNO-NOT: .conj +// NO__ERRNO-NOT: @conj +// HAS_ERRNO-NOT: .conj +// HAS_ERRNO-NOT: @conj clog(f); clogf(f); clogl(f); @@ -133,7 +131,7 @@ void foo(float f) { // NO__ERRNO: declare { double, double } @cproj(double, double) [[READNONE]] // NO__ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]] // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]] -// HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE]] +// HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE:#[0-9]+]] // HAS_ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]] // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]] _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits