[llvm-branch-commits] [llvm] AMDGPU: Make fmul_legacy intrinsic propagate poison (PR #131062)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Mar 12 20:49:50 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/131062.diff
2 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp (+5)
- (modified) llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll (+16)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index 083fa2a730fff..ba4e6e530fe56 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -1255,6 +1255,11 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
Value *Op0 = II.getArgOperand(0);
Value *Op1 = II.getArgOperand(1);
+ for (Value *Src : {Op0, Op1}) {
+ if (isa<PoisonValue>(Src))
+ return IC.replaceInstUsesWith(II, Src);
+ }
+
// The legacy behaviour is that multiplying +/-0.0 by anything, even NaN or
// infinity, gives +0.0.
// TODO: Move to InstSimplify?
diff --git a/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll b/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
index d58470d6b12ad..899b611b929d1 100644
--- a/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
+++ b/llvm/test/Transforms/InstCombine/AMDGPU/fmul_legacy.ll
@@ -75,6 +75,22 @@ define float @test_finite_assumed(float %x, float %y) {
ret float %call
}
+define float @test_poison_var(float %x) {
+; CHECK-LABEL: @test_poison_var(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fmul.legacy(float poison, float %x)
+ ret float %call
+}
+
+define float @test_var_poison(float %x) {
+; CHECK-LABEL: @test_var_poison(
+; CHECK-NEXT: ret float poison
+;
+ %call = call float @llvm.amdgcn.fmul.legacy(float %x, float poison)
+ ret float %call
+}
+
declare float @llvm.amdgcn.fmul.legacy(float, float)
declare float @llvm.fabs.f32(float)
declare void @llvm.assume(i1 noundef)
``````````
</details>
https://github.com/llvm/llvm-project/pull/131062
More information about the llvm-branch-commits
mailing list