Skip to content

Commit 8733392

Browse files
committed
[Flang] Force lowering to Complex for AMDGPU
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.
1 parent 35f6d91 commit 8733392

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,11 @@ mlir::Value genComplexMathOp(fir::FirOpBuilder &builder, mlir::Location loc,
12281228
llvm::StringRef mathLibFuncName = mathOp.runtimeFunc;
12291229
if (!mathLibFuncName.empty()) {
12301230
// If we enabled MLIR complex or can use approximate operations, we should
1231-
// NOT use libm.
1232-
if (!forceMlirComplex && !canUseApprox) {
1231+
// NOT use libm. Avoid libm when targeting AMDGPU as those symbols are not
1232+
// available on the device and we rely on MLIR complex operations to
1233+
// later map to OCML calls.
1234+
bool isAMDGPU = fir::getTargetTriple(builder.getModule()).isAMDGCN();
1235+
if (!forceMlirComplex && !canUseApprox && !isAMDGPU) {
12331236
result = genLibCall(builder, loc, mathOp, mathLibFuncType, args);
12341237
LLVM_DEBUG(result.dump(); llvm::dbgs() << "\n");
12351238
return result;

0 commit comments

Comments
 (0)