https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/130915
None >From cd50fad71b6cd07d029fa055f52580d1903ece27 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Wed, 12 Mar 2025 14:11:51 +0700 Subject: [PATCH] AMDGPU: Make frexp_exp and frexp_mant intrinsics propagate poison --- .../Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp | 3 +++ .../InstCombine/AMDGPU/amdgcn-intrinsics.ll | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp index 5314738b2b8ac..bf53018439e9f 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp @@ -636,6 +636,9 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const { return IC.replaceInstUsesWith(II, ConstantInt::get(II.getType(), Exp)); } + if (isa<PoisonValue>(Src)) + return IC.replaceInstUsesWith(II, PoisonValue::get(II.getType())); + if (isa<UndefValue>(Src)) { return IC.replaceInstUsesWith(II, UndefValue::get(II.getType())); } diff --git a/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll b/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll index fca3860240294..78606b1c869d1 100644 --- a/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll @@ -274,6 +274,14 @@ declare float @llvm.amdgcn.frexp.mant.f32(float) nounwind readnone declare double @llvm.amdgcn.frexp.mant.f64(double) nounwind readnone +define float @test_constant_fold_frexp_mant_f32_poison() nounwind { +; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_poison( +; CHECK-NEXT: ret float poison +; + %val = call float @llvm.amdgcn.frexp.mant.f32(float poison) + ret float %val +} + define float @test_constant_fold_frexp_mant_f32_undef() nounwind { ; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_undef( ; CHECK-NEXT: ret float undef @@ -442,6 +450,14 @@ define double @test_constant_fold_frexp_mant_f64_min_num() nounwind { declare i32 @llvm.amdgcn.frexp.exp.f32(float) nounwind readnone declare i32 @llvm.amdgcn.frexp.exp.f64(double) nounwind readnone +define i32 @test_constant_fold_frexp_exp_f32_poison() nounwind { +; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_poison( +; CHECK-NEXT: ret i32 poison +; + %val = call i32 @llvm.amdgcn.frexp.exp.f32(float poison) + ret i32 %val +} + define i32 @test_constant_fold_frexp_exp_f32_undef() nounwind { ; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_undef( ; CHECK-NEXT: ret i32 undef _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits