Skip to content

Commit 5deb2aa

Browse files
authored
AMDGPU: Make is.shared and is.private propagate poison (llvm#128617)
1 parent eab6f2d commit 5deb2aa

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,10 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
12561256
}
12571257
case Intrinsic::amdgcn_is_shared:
12581258
case Intrinsic::amdgcn_is_private: {
1259-
if (isa<UndefValue>(II.getArgOperand(0)))
1259+
Value *Src = II.getArgOperand(0);
1260+
if (isa<PoisonValue>(Src))
1261+
return IC.replaceInstUsesWith(II, PoisonValue::get(II.getType()));
1262+
if (isa<UndefValue>(Src))
12601263
return IC.replaceInstUsesWith(II, UndefValue::get(II.getType()));
12611264

12621265
if (isa<ConstantPointerNull>(II.getArgOperand(0)))

llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5671,6 +5671,14 @@ define i1 @test_is_shared_undef() nounwind {
56715671
ret i1 %val
56725672
}
56735673

5674+
define i1 @test_is_shared_poison() nounwind {
5675+
; CHECK-LABEL: @test_is_shared_poison(
5676+
; CHECK-NEXT: ret i1 poison
5677+
;
5678+
%val = call i1 @llvm.amdgcn.is.shared(ptr poison)
5679+
ret i1 %val
5680+
}
5681+
56745682
; --------------------------------------------------------------------
56755683
; llvm.amdgcn.is.private
56765684
; --------------------------------------------------------------------
@@ -5693,6 +5701,14 @@ define i1 @test_is_private_undef() nounwind {
56935701
ret i1 %val
56945702
}
56955703

5704+
define i1 @test_is_private_poison() nounwind {
5705+
; CHECK-LABEL: @test_is_private_poison(
5706+
; CHECK-NEXT: ret i1 poison
5707+
;
5708+
%val = call i1 @llvm.amdgcn.is.private(ptr poison)
5709+
ret i1 %val
5710+
}
5711+
56965712
; --------------------------------------------------------------------
56975713
; llvm.amdgcn.trig.preop
56985714
; --------------------------------------------------------------------

0 commit comments

Comments
 (0)