[llvm] 0a78bd6 - AMDGPU: Make frexp_exp and frexp_mant intrinsics propagate poison (#130915)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 12 20:07:48 PDT 2025
Author: Matt Arsenault
Date: 2025-03-13T10:07:45+07:00
New Revision: 0a78bd67b311e418d44f3975b9fd9f62cdbe56c6
URL: https://github.com/llvm/llvm-project/commit/0a78bd67b311e418d44f3975b9fd9f62cdbe56c6
DIFF: https://github.com/llvm/llvm-project/commit/0a78bd67b311e418d44f3975b9fd9f62cdbe56c6.diff
LOG: AMDGPU: Make frexp_exp and frexp_mant intrinsics propagate poison (#130915)
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
Removed:
################################################################################
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
More information about the llvm-commits
mailing list