https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/131062
None >From 5f4a37dcdb2d6bf9e503bab459d92067e2d885e9 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Thu, 13 Mar 2025 10:46:42 +0700 Subject: [PATCH] AMDGPU: Make fmul_legacy intrinsic propagate poison --- .../Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp | 5 +++++ .../Transforms/InstCombine/AMDGPU/fmul_legacy.ll | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) 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) _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits