[flang][cuda] Use NVVM op for clock64#149223
Merged
clementval merged 1 commit intollvm:mainfrom Jul 17, 2025
Merged
Conversation
Member
|
@llvm/pr-subscribers-flang-fir-hlfir Author: Valentin Clement (バレンタイン クレメン) (clementval) ChangesNVVM op is now available for clock64 Full diff: https://github.com/llvm/llvm-project/pull/149223.diff 2 Files Affected:
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 8d0a511744e25..e9a1753a537a1 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -3563,11 +3563,7 @@ IntrinsicLibrary::genChdir(std::optional<mlir::Type> resultType,
// CLOCK64
mlir::Value IntrinsicLibrary::genClock64(mlir::Type resultType,
llvm::ArrayRef<mlir::Value> args) {
- constexpr llvm::StringLiteral funcName = "llvm.nvvm.read.ptx.sreg.clock64";
- mlir::MLIRContext *context = builder.getContext();
- mlir::FunctionType ftype = mlir::FunctionType::get(context, {}, {resultType});
- auto funcOp = builder.createFunction(loc, funcName, ftype);
- return builder.create<fir::CallOp>(loc, funcOp, args).getResult(0);
+ return builder.create<mlir::NVVM::Clock64Op>(loc, resultType).getResult();
}
// CMPLX
diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf
index 42ee7657966e2..0f72a0d89f3e7 100644
--- a/flang/test/Lower/CUDA/cuda-device-proc.cuf
+++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf
@@ -82,7 +82,7 @@ end
! CHECK: %{{.*}} = llvm.atomicrmw uinc_wrap %{{.*}}, %{{.*}} seq_cst : !llvm.ptr, i32
! CHECK: %{{.*}} = llvm.atomicrmw udec_wrap %{{.*}}, %{{.*}} seq_cst : !llvm.ptr, i32
-! CHECK: fir.call @llvm.nvvm.read.ptx.sreg.clock64()
+! CHECK: %{{.*}} = nvvm.read.ptx.sreg.clock64 : i64
subroutine host1()
integer, device :: a(32)
|
wangzpgi
approved these changes
Jul 16, 2025
37cdca0 to
c74484d
Compare
This was referenced Jul 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NVVM op is now available for clock64