Skip to content

Commit 3770689

Browse files
authored
AMDGPU: Make fmul_legacy intrinsic propagate poison (#131062)
1 parent a716459 commit 3770689

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,11 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
12561256
Value *Op0 = II.getArgOperand(0);
12571257
Value *Op1 = II.getArgOperand(1);
12581258

1259+
for (Value *Src : {Op0, Op1}) {
1260+
if (isa<PoisonValue>(Src))
1261+
return IC.replaceInstUsesWith(II, Src);
1262+
}
1263+
12591264
// The legacy behaviour is that multiplying +/-0.0 by anything, even NaN or
12601265
// infinity, gives +0.0.
12611266
// TODO: Move to InstSimplify?

llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ define float @test_finite_assumed(float %x, float %y) {
7575
ret float %call
7676
}
7777

78+
define float @test_poison_var(float %x) {
79+
; CHECK-LABEL: @test_poison_var(
80+
; CHECK-NEXT: ret float poison
81+
;
82+
%call = call float @llvm.amdgcn.fmul.legacy(float poison, float %x)
83+
ret float %call
84+
}
85+
86+
define float @test_var_poison(float %x) {
87+
; CHECK-LABEL: @test_var_poison(
88+
; CHECK-NEXT: ret float poison
89+
;
90+
%call = call float @llvm.amdgcn.fmul.legacy(float %x, float poison)
91+
ret float %call
92+
}
93+
7894
declare float @llvm.amdgcn.fmul.legacy(float, float)
7995
declare float @llvm.fabs.f32(float)
8096
declare void @llvm.assume(i1 noundef)

0 commit comments

Comments
 (0)