https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/131063

>From 45508d81234b41c9cf79f4031bfbbdae44026e21 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <matthew.arsena...@amd.com>
Date: Thu, 13 Mar 2025 10:48:15 +0700
Subject: [PATCH] AMDGPU: Make fma_legacy intrinsic propagate poison

---
 .../AMDGPU/AMDGPUInstCombineIntrinsic.cpp     |  5 ++++
 .../InstCombine/AMDGPU/fma_legacy.ll          | 24 +++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index b92f1bdd6a801..0bbded6a3422a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -1282,6 +1282,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)

_______________________________________________
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