Skip to content

Commit 0a78bd6

Browse files
authored
AMDGPU: Make frexp_exp and frexp_mant intrinsics propagate poison (#130915)
1 parent 4d8070e commit 0a78bd6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,9 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
636636
return IC.replaceInstUsesWith(II, ConstantInt::get(II.getType(), Exp));
637637
}
638638

639+
if (isa<PoisonValue>(Src))
640+
return IC.replaceInstUsesWith(II, PoisonValue::get(II.getType()));
641+
639642
if (isa<UndefValue>(Src)) {
640643
return IC.replaceInstUsesWith(II, UndefValue::get(II.getType()));
641644
}

llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ declare float @llvm.amdgcn.frexp.mant.f32(float) nounwind readnone
274274
declare double @llvm.amdgcn.frexp.mant.f64(double) nounwind readnone
275275

276276

277+
define float @test_constant_fold_frexp_mant_f32_poison() nounwind {
278+
; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_poison(
279+
; CHECK-NEXT: ret float poison
280+
;
281+
%val = call float @llvm.amdgcn.frexp.mant.f32(float poison)
282+
ret float %val
283+
}
284+
277285
define float @test_constant_fold_frexp_mant_f32_undef() nounwind {
278286
; CHECK-LABEL: @test_constant_fold_frexp_mant_f32_undef(
279287
; CHECK-NEXT: ret float undef
@@ -442,6 +450,14 @@ define double @test_constant_fold_frexp_mant_f64_min_num() nounwind {
442450
declare i32 @llvm.amdgcn.frexp.exp.f32(float) nounwind readnone
443451
declare i32 @llvm.amdgcn.frexp.exp.f64(double) nounwind readnone
444452

453+
define i32 @test_constant_fold_frexp_exp_f32_poison() nounwind {
454+
; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_poison(
455+
; CHECK-NEXT: ret i32 poison
456+
;
457+
%val = call i32 @llvm.amdgcn.frexp.exp.f32(float poison)
458+
ret i32 %val
459+
}
460+
445461
define i32 @test_constant_fold_frexp_exp_f32_undef() nounwind {
446462
; CHECK-LABEL: @test_constant_fold_frexp_exp_f32_undef(
447463
; CHECK-NEXT: ret i32 undef

0 commit comments

Comments
 (0)