[flang-commits] [flang] [Flang] Force lowering to Complex for AMDGPU (PR #144927)
via flang-commits
flang-commits at lists.llvm.org
Thu Jun 19 09:52:14 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Akash Banerjee (TIFitis)
<details>
<summary>Changes</summary>
Avoid libm when targeting AMDGPU as those symbols are not available on the device and we rely on MLIR complex operations to later map to OCML calls.
PRs #<!-- -->144924 & #<!-- -->144926 add additional related support.
---
Full diff: https://github.com/llvm/llvm-project/pull/144927.diff
1 Files Affected:
- (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+5-2)
``````````diff
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 178b6770d6b53..2ca7f2784aab3 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -1228,8 +1228,11 @@ mlir::Value genComplexMathOp(fir::FirOpBuilder &builder, mlir::Location loc,
llvm::StringRef mathLibFuncName = mathOp.runtimeFunc;
if (!mathLibFuncName.empty()) {
// If we enabled MLIR complex or can use approximate operations, we should
- // NOT use libm.
- if (!forceMlirComplex && !canUseApprox) {
+ // NOT use libm. Avoid libm when targeting AMDGPU as those symbols are not
+ // available on the device and we rely on MLIR complex operations to
+ // later map to OCML calls.
+ bool isAMDGPU = fir::getTargetTriple(builder.getModule()).isAMDGCN();
+ if (!forceMlirComplex && !canUseApprox && !isAMDGPU) {
result = genLibCall(builder, loc, mathOp, mathLibFuncType, args);
LLVM_DEBUG(result.dump(); llvm::dbgs() << "\n");
return result;
``````````
</details>
https://github.com/llvm/llvm-project/pull/144927
More information about the flang-commits
mailing list