Skip to content

AMDGPU: Make is.shared and is.private propagate poison #128617

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

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Feb 25, 2025

No description provided.

Copy link
Contributor Author

arsenm commented Feb 25, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Feb 25, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/128617.diff

2 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp (+4-1)
  • (modified) llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll (+16)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index bac3bb5fde7b0..ebc00e59584ac 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -1256,7 +1256,10 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
   }
   case Intrinsic::amdgcn_is_shared:
   case Intrinsic::amdgcn_is_private: {
-    if (isa<UndefValue>(II.getArgOperand(0)))
+    Value *Src = II.getArgOperand(0);
+    if (isa<PoisonValue>(Src))
+      return IC.replaceInstUsesWith(II, PoisonValue::get(II.getType()));
+    if (isa<UndefValue>(Src))
       return IC.replaceInstUsesWith(II, UndefValue::get(II.getType()));
 
     if (isa<ConstantPointerNull>(II.getArgOperand(0)))
diff --git a/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll b/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
index 5fdb918c87545..aafe8105482d2 100644
--- a/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
@@ -5671,6 +5671,14 @@ define i1 @test_is_shared_undef() nounwind {
   ret i1 %val
 }
 
+define i1 @test_is_shared_poison() nounwind {
+; CHECK-LABEL: @test_is_shared_poison(
+; CHECK-NEXT:    ret i1 poison
+;
+  %val = call i1 @llvm.amdgcn.is.shared(ptr poison)
+  ret i1 %val
+}
+
 ; --------------------------------------------------------------------
 ; llvm.amdgcn.is.private
 ; --------------------------------------------------------------------
@@ -5693,6 +5701,14 @@ define i1 @test_is_private_undef() nounwind {
   ret i1 %val
 }
 
+define i1 @test_is_private_poison() nounwind {
+; CHECK-LABEL: @test_is_private_poison(
+; CHECK-NEXT:    ret i1 poison
+;
+  %val = call i1 @llvm.amdgcn.is.private(ptr poison)
+  ret i1 %val
+}
+
 ; --------------------------------------------------------------------
 ; llvm.amdgcn.trig.preop
 ; --------------------------------------------------------------------

@arsenm arsenm marked this pull request as ready for review February 25, 2025 02:29
@arsenm arsenm force-pushed the users/arsenm/amdgpu/make-is-shared-is-private-propagate-poison branch from feca2a8 to c5d0362 Compare February 25, 2025 02:35
Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good but what is the benefit of doing it?

@arsenm
Copy link
Contributor Author

arsenm commented Feb 25, 2025

It looks good but what is the benefit of doing it?

poison folds out better and we want to get rid of undef

@arsenm arsenm merged commit 5deb2aa into main Feb 25, 2025
11 checks passed
@arsenm arsenm deleted the users/arsenm/amdgpu/make-is-shared-is-private-propagate-poison branch February 25, 2025 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants