llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/131063.diff


2 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp (+5) 
- (modified) llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll (+24) 


``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index ba4e6e530fe56..86f33f33d1fc7 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -1281,6 +1281,11 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, 
IntrinsicInst &II) const {
     Value *Op1 = II.getArgOperand(1);
     Value *Op2 = II.getArgOperand(2);
 
+    for (Value *Src : {Op0, Op1, Op2}) {
+      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/fma_legacy.ll 
b/llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll
index 72bffe62fbb14..b2f851d6d56ed 100644
--- a/llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll
+++ b/llvm/test/Transforms/InstCombine/AMDGPU/fma_legacy.ll
@@ -105,6 +105,30 @@ define float @test_finite_assumed(float %x, float %y, 
float %z) {
   ret float %call
 }
 
+define float @test_poison_x_y(float %x, float %y) {
+; CHECK-LABEL: @test_poison_x_y(
+; CHECK-NEXT:    ret float poison
+;
+  %call = call float @llvm.amdgcn.fma.legacy(float poison, float %x, float %y)
+  ret float %call
+}
+
+define float @test_x_poison_y(float %x, float %y) {
+; CHECK-LABEL: @test_x_poison_y(
+; CHECK-NEXT:    ret float poison
+;
+  %call = call float @llvm.amdgcn.fma.legacy(float %x, float poison, float %y)
+  ret float %call
+}
+
+define float @test_x_y_poison_y(float %x, float %y) {
+; CHECK-LABEL: @test_x_y_poison_y(
+; CHECK-NEXT:    ret float poison
+;
+  %call = call float @llvm.amdgcn.fma.legacy(float %x, float %y, float poison)
+  ret float %call
+}
+
 declare float @llvm.amdgcn.fma.legacy(float, float, float)
 declare float @llvm.fabs.f32(float)
 declare void @llvm.assume(i1 noundef)

``````````

</details>


https://github.com/llvm/llvm-project/pull/131063
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to