[PATCH] D115669: AMDGPU: Combine is.shared/is.private of null/undef

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 13 13:17:15 PST 2021


arsenm created this revision.
arsenm added a reviewer: rampitec.
Herald added subscribers: foad, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

https://reviews.llvm.org/D115669

Files:
  llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
  llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll


Index: llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
===================================================================
--- llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
+++ llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
@@ -3922,3 +3922,47 @@
   store <4 x float> %res, <4 x float> addrspace(1)* %out
   ret void
 }
+
+; --------------------------------------------------------------------
+; llvm.amdgcn.is.shared
+; --------------------------------------------------------------------
+
+declare i1 @llvm.amdgcn.is.shared(i8*) nounwind readnone
+
+define i1 @test_is_shared_null() nounwind {
+; CHECK-LABEL: @test_is_shared_null(
+; CHECK-NEXT:    ret i1 false
+;
+  %val = call i1 @llvm.amdgcn.is.shared(i8* null)
+  ret i1 %val
+}
+
+define i1 @test_is_shared_undef() nounwind {
+; CHECK-LABEL: @test_is_shared_undef(
+; CHECK-NEXT:    ret i1 undef
+;
+  %val = call i1 @llvm.amdgcn.is.shared(i8* undef)
+  ret i1 %val
+}
+
+; --------------------------------------------------------------------
+; llvm.amdgcn.is.private
+; --------------------------------------------------------------------
+
+declare i1 @llvm.amdgcn.is.private(i8*) nounwind readnone
+
+define i1 @test_is_private_null() nounwind {
+; CHECK-LABEL: @test_is_private_null(
+; CHECK-NEXT:    ret i1 false
+;
+  %val = call i1 @llvm.amdgcn.is.private(i8* null)
+  ret i1 %val
+}
+
+define i1 @test_is_private_undef() nounwind {
+; CHECK-LABEL: @test_is_private_undef(
+; CHECK-NEXT:    ret i1 undef
+;
+  %val = call i1 @llvm.amdgcn.is.private(i8* undef)
+  ret i1 %val
+}
Index: llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -892,6 +892,15 @@
     }
     break;
   }
+  case Intrinsic::amdgcn_is_shared:
+  case Intrinsic::amdgcn_is_private: {
+    if (isa<UndefValue>(II.getArgOperand(0)))
+      return IC.replaceInstUsesWith(II, UndefValue::get(II.getType()));
+
+    if (isa<ConstantPointerNull>(II.getArgOperand(0)))
+      return IC.replaceInstUsesWith(II, ConstantInt::getFalse(II.getType()));
+    break;
+  }
   default: {
     if (const AMDGPU::ImageDimIntrinsicInfo *ImageDimIntr =
             AMDGPU::getImageDimIntrinsicInfo(II.getIntrinsicID())) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115669.394026.patch
Type: text/x-patch
Size: 2376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211213/f5d002f9/attachment.bin>


More information about the llvm-commits mailing list