-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NVPTX] Remove 'param' variants of nvvm.ptr.* intrinics #137065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexMaclean
merged 1 commit into
llvm:main
from
AlexMaclean:dev/amaclean/upstream/remove-nvvm.ptr.param
Apr 25, 2025
Merged
[NVPTX] Remove 'param' variants of nvvm.ptr.* intrinics #137065
AlexMaclean
merged 1 commit into
llvm:main
from
AlexMaclean:dev/amaclean/upstream/remove-nvvm.ptr.param
Apr 25, 2025
Conversation
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
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-nvptx Author: Alex MacLean (AlexMaclean) ChangesAfter #136008 these intrinsics are no longer inserted by the compiler and can be upgraded to addrspacecasts. Full diff: https://github.com/llvm/llvm-project/pull/137065.diff 4 Files Affected:
diff --git a/llvm/include/llvm/IR/IntrinsicsNVVM.td b/llvm/include/llvm/IR/IntrinsicsNVVM.td
index 94367be6ee8e2..2c550de7a9203 100644
--- a/llvm/include/llvm/IR/IntrinsicsNVVM.td
+++ b/llvm/include/llvm/IR/IntrinsicsNVVM.td
@@ -116,10 +116,12 @@
// * llvm.nvvm.ptr.gen.to.shared --> ibid.
// * llvm.nvvm.ptr.gen.to.constant --> ibid.
// * llvm.nvvm.ptr.gen.to.local --> ibid.
+// * llvm.nvvm.ptr.gen.to.param --> ibid.
// * llvm.nvvm.ptr.global.to.gen --> ibid.
// * llvm.nvvm.ptr.shared.to.gen --> ibid.
// * llvm.nvvm.ptr.constant.to.gen --> ibid.
// * llvm.nvvm.ptr.local.to.gen --> ibid.
+// * llvm.nvvm.ptr.param.to.gen --> ibid.
// * llvm.nvvm.ldg.global.i --> load addrspace(1) !load.invariant
// * llvm.nvvm.ldg.global.f --> ibid.
// * llvm.nvvm.ldg.global.p --> ibid.
@@ -1897,19 +1899,6 @@ def int_nvvm_ldu_global_p : Intrinsic<[llvm_anyptr_ty],
[IntrReadMem, IntrArgMemOnly, IntrNoCallback, IntrWillReturn, NoCapture<ArgIndex<0>>],
"llvm.nvvm.ldu.global.p">;
-// Used in nvvm internally to help address space opt and ptx code generation
-// This is for params that are passed to kernel functions by pointer by-val.
-def int_nvvm_ptr_gen_to_param: Intrinsic<[llvm_anyptr_ty],
- [llvm_anyptr_ty],
- [IntrNoMem, IntrSpeculatable, IntrNoCallback],
- "llvm.nvvm.ptr.gen.to.param">;
-
-// sm70+, PTX7.7+
-def int_nvvm_ptr_param_to_gen: DefaultAttrsIntrinsic<[llvm_anyptr_ty],
- [llvm_anyptr_ty],
- [IntrNoMem, IntrSpeculatable, IntrNoCallback],
- "llvm.nvvm.ptr.param.to.gen">;
-
// Represents an explicit hole in the LLVM IR type system. It may be inserted by
// the compiler in cases where a pointer is of the wrong type. In the backend
// this intrinsic will be folded away and not equate to any instruction. It
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 01e9b61b38944..2fd5b715b078f 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1054,6 +1054,12 @@ static Intrinsic::ID shouldUpgradeNVPTXBF16Intrinsic(StringRef Name) {
return Intrinsic::not_intrinsic;
}
+static bool consumeNVVMPtrAddrSpace(StringRef &Name) {
+ return Name.consume_front("local") || Name.consume_front("shared") ||
+ Name.consume_front("global") || Name.consume_front("constant") ||
+ Name.consume_front("param");
+}
+
static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
bool CanUpgradeDebugIntrinsicsToRecords) {
assert(F && "Illegal to upgrade a non-existent Function.");
@@ -1361,15 +1367,11 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
// nvvm.rotate.{b32,b64,right.b64}
Expand = Name == "b32" || Name == "b64" || Name == "right.b64";
else if (Name.consume_front("ptr.gen.to."))
- // nvvm.ptr.gen.to.{local,shared,global,constant}
- Expand = Name.starts_with("local") || Name.starts_with("shared") ||
- Name.starts_with("global") || Name.starts_with("constant");
+ // nvvm.ptr.gen.to.{local,shared,global,constant,param}
+ Expand = consumeNVVMPtrAddrSpace(Name);
else if (Name.consume_front("ptr."))
- // nvvm.ptr.{local,shared,global,constant}.to.gen
- Expand =
- (Name.consume_front("local") || Name.consume_front("shared") ||
- Name.consume_front("global") || Name.consume_front("constant")) &&
- Name.starts_with(".to.gen");
+ // nvvm.ptr.{local,shared,global,constant,param}.to.gen
+ Expand = consumeNVVMPtrAddrSpace(Name) && Name.starts_with(".to.gen");
else if (Name.consume_front("ldg.global."))
// nvvm.ldg.global.{i,p,f}
Expand = (Name.starts_with("i.") || Name.starts_with("f.") ||
@@ -2450,12 +2452,8 @@ static Value *upgradeNVVMIntrinsicCall(StringRef Name, CallBase *CI,
Rep = Builder.CreateIntrinsic(Int64Ty, Intrinsic::fshl,
{Arg, Arg, Builder.getInt64(32)});
} else if ((Name.consume_front("ptr.gen.to.") &&
- (Name.starts_with("local") || Name.starts_with("shared") ||
- Name.starts_with("global") || Name.starts_with("constant"))) ||
- (Name.consume_front("ptr.") &&
- (Name.consume_front("local") || Name.consume_front("shared") ||
- Name.consume_front("global") ||
- Name.consume_front("constant")) &&
+ consumeNVVMPtrAddrSpace(Name)) ||
+ (Name.consume_front("ptr.") && consumeNVVMPtrAddrSpace(Name) &&
Name.starts_with(".to.gen"))) {
Rep = Builder.CreateAddrSpaceCast(CI->getArgOperand(0), CI->getType());
} else if (Name.consume_front("ldg.global")) {
diff --git a/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td b/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
index a6595e512dbae..3eedb43e4c81a 100644
--- a/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ b/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -2413,18 +2413,6 @@ foreach space = ["local", "shared", "global", "const", "param"] in {
defm cvta_shared_cluster : NG_TO_G<"shared::cluster", false, [hasClusters]>;
defm cvta_to_shared_cluster : G_TO_NG<"shared::cluster", false, [hasClusters]>;
-def : Pat<(int_nvvm_ptr_param_to_gen i32:$src),
- (cvta_param $src)>;
-
-def : Pat<(int_nvvm_ptr_param_to_gen i64:$src),
- (cvta_param_64 $src)>;
-
-// nvvm.ptr.gen.to.param
-def : Pat<(int_nvvm_ptr_gen_to_param i32:$src),
- (i32 Int32Regs:$src)>;
-
-def : Pat<(int_nvvm_ptr_gen_to_param i64:$src),
- (i64 Int64Regs:$src)>;
// nvvm.move intrinsicc
def nvvm_move_i16 : NVPTXInst<(outs Int16Regs:$r), (ins Int16Regs:$s),
diff --git a/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll b/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
index 9b1dd7088f1dd..98ffa23fae64b 100644
--- a/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
+++ b/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
@@ -44,10 +44,12 @@ declare ptr addrspace(1) @llvm.nvvm.ptr.gen.to.global.p1.p0(ptr)
declare ptr addrspace(3) @llvm.nvvm.ptr.gen.to.shared.p3.p0(ptr)
declare ptr addrspace(4) @llvm.nvvm.ptr.gen.to.constant.p4.p0(ptr)
declare ptr addrspace(5) @llvm.nvvm.ptr.gen.to.local.p5.p0(ptr)
+declare ptr addrspace(101) @llvm.nvvm.ptr.gen.to.param.p101.p0(ptr)
declare ptr @llvm.nvvm.ptr.global.to.gen.p0.p1(ptr addrspace(1))
declare ptr @llvm.nvvm.ptr.shared.to.gen.p0.p3(ptr addrspace(3))
declare ptr @llvm.nvvm.ptr.constant.to.gen.p0.p4(ptr addrspace(4))
declare ptr @llvm.nvvm.ptr.local.to.gen.p0.p5(ptr addrspace(5))
+declare ptr @llvm.nvvm.ptr.param.to.gen.p0.p101(ptr addrspace(101))
declare i32 @llvm.nvvm.ldg.global.i.i32.p1(ptr addrspace(1), i32)
declare ptr @llvm.nvvm.ldg.global.p.p1(ptr addrspace(1), i32)
@@ -219,6 +221,8 @@ define void @addrspacecast(ptr %p0) {
; CHECK: %6 = addrspacecast ptr addrspace(4) %5 to ptr
; CHECK: %7 = addrspacecast ptr %6 to ptr addrspace(5)
; CHECK: %8 = addrspacecast ptr addrspace(5) %7 to ptr
+; CHECK: %9 = addrspacecast ptr %8 to ptr addrspace(101)
+; CHECK: %10 = addrspacecast ptr addrspace(101) %9 to ptr
;
%p1 = call ptr addrspace(1) @llvm.nvvm.ptr.gen.to.global.p1.p0(ptr %p0)
%p2 = call ptr @llvm.nvvm.ptr.global.to.gen.p0.p1(ptr addrspace(1) %p1)
@@ -232,6 +236,9 @@ define void @addrspacecast(ptr %p0) {
%p7 = call ptr addrspace(5) @llvm.nvvm.ptr.gen.to.local.p5.p0(ptr %p6)
%p8 = call ptr @llvm.nvvm.ptr.local.to.gen.p0.p5(ptr addrspace(5) %p7)
+ %p9 = call ptr addrspace(101) @llvm.nvvm.ptr.gen.to.param.p101.p0(ptr %p8)
+ %p10 = call ptr @llvm.nvvm.ptr.param.to.gen.p0.p101(ptr addrspace(101) %p9)
+
ret void
}
|
justinfargnoli
approved these changes
Apr 24, 2025
Artem-B
approved these changes
Apr 25, 2025
jyli0116
pushed a commit
to jyli0116/llvm-project
that referenced
this pull request
Apr 28, 2025
After llvm#136008 these intrinsics are no longer inserted by the compiler and can be upgraded to addrspacecasts.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
After llvm#136008 these intrinsics are no longer inserted by the compiler and can be upgraded to addrspacecasts.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
After llvm#136008 these intrinsics are no longer inserted by the compiler and can be upgraded to addrspacecasts.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
After llvm#136008 these intrinsics are no longer inserted by the compiler and can be upgraded to addrspacecasts.
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
May 9, 2025
After llvm#136008 these intrinsics are no longer inserted by the compiler and can be upgraded to addrspacecasts.
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.
After #136008 these intrinsics are no longer inserted by the compiler and can be upgraded to addrspacecasts.