Skip to content

Commit 2b21ffa

Browse files
committed
AMDGPU: Make rcp intrinsic propagate poison
1 parent eea7d32 commit 2b21ffa

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
487487
switch (IID) {
488488
case Intrinsic::amdgcn_rcp: {
489489
Value *Src = II.getArgOperand(0);
490+
if (isa<PoisonValue>(Src))
491+
return IC.replaceInstUsesWith(II, Src);
490492

491493
// TODO: Move to ConstantFolding/InstSimplify?
492494
if (isa<UndefValue>(Src)) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
declare float @llvm.amdgcn.rcp.f32(float) nounwind readnone
99
declare double @llvm.amdgcn.rcp.f64(double) nounwind readnone
1010

11+
define float @test_constant_fold_rcp_f32_poison() nounwind {
12+
; CHECK-LABEL: @test_constant_fold_rcp_f32_poison(
13+
; CHECK-NEXT: ret float poison
14+
;
15+
%val = call float @llvm.amdgcn.rcp.f32(float poison) nounwind readnone
16+
ret float %val
17+
}
18+
1119
define float @test_constant_fold_rcp_f32_undef() nounwind {
1220
; CHECK-LABEL: @test_constant_fold_rcp_f32_undef(
1321
; CHECK-NEXT: ret float 0x7FF8000000000000

0 commit comments

Comments
 (0)