Skip to content

Commit 74f3cc0

Browse files
authored
[flang] Call __clog instead of clog on AIX (#111442)
1 parent 4582651 commit 74f3cc0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,13 @@ mlir::Value genLibCall(fir::FirOpBuilder &builder, mlir::Location loc,
774774
mlir::FunctionType libFuncType,
775775
llvm::ArrayRef<mlir::Value> args) {
776776
llvm::StringRef libFuncName = mathOp.runtimeFunc;
777+
778+
// On AIX, __clog is used in libm.
779+
if (fir::getTargetTriple(builder.getModule()).isOSAIX() &&
780+
libFuncName == "clog") {
781+
libFuncName = "__clog";
782+
}
783+
777784
LLVM_DEBUG(llvm::dbgs() << "Generating '" << libFuncName
778785
<< "' call with type ";
779786
libFuncType.dump(); llvm::dbgs() << "\n");

flang/test/Lower/Intrinsics/log.f90

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
! RUN: bbc -emit-fir -hlfir=false -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CHECK,CMPLX,CMPLX-PRECISE"
2-
! RUN: bbc -emit-fir -hlfir=false --math-runtime=precise -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-PRECISE"
1+
! RUN: bbc -emit-fir -hlfir=false -outline-intrinsics %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CHECK,CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CHECK,CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
2+
! RUN: bbc -emit-fir -hlfir=false --math-runtime=precise -outline-intrinsics %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
33
! RUN: bbc -emit-fir -hlfir=false --force-mlir-complex -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-FAST,CMPLX-MLIR"
4-
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CHECK,CMPLX,CMPLX-PRECISE"
5-
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics -mllvm --math-runtime=precise %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-PRECISE"
4+
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CHECK,CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CHECK,CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
5+
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics -mllvm --math-runtime=precise %s -o - | FileCheck %s --check-prefixes=%if system-aix %{"CMPLX,CMPLX-PRECISE,AIX-LOG"%} %else %{"CMPLX,CMPLX-PRECISE,COMMON-LOG"%}
66
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics -mllvm --force-mlir-complex %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-FAST,CMPLX-MLIR"
77
! RUN: %flang_fc1 -fapprox-func -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-APPROX"
88

@@ -91,7 +91,8 @@ subroutine log10_testd(a, b)
9191
! CMPLX-SAME: (%[[C:.*]]: complex<f64>) -> complex<f64>
9292
! CMPLX-FAST: %[[E:.*]] = complex.log %[[C]] fastmath<contract> : complex<f64>
9393
! CMPLX-APPROX: %[[E:.*]] = complex.log %[[C]] fastmath<contract,afn> : complex<f64>
94-
! CMPLX-PRECISE: %[[E:.*]] = fir.call @clog(%[[C]]) fastmath<contract> : (complex<f64>) -> complex<f64>
94+
! COMMON-LOG: %[[E:.*]] = fir.call @clog(%[[C]]) fastmath<contract> : (complex<f64>) -> complex<f64>
95+
! AIX-LOG: %[[E:.*]] = fir.call @__clog(%[[C]]) fastmath<contract> : (complex<f64>) -> complex<f64>
9596
! CMPLX: return %[[E]] : complex<f64>
9697

9798
! CHECK-LABEL: private @fir.log10.contract.f32.f32

0 commit comments

Comments
 (0)