[llvm] 6e934f2 - AMDGPU: Add baseline tests for llvm.amdgcn.exp2 folds

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 04:02:42 PDT 2023


Author: Matt Arsenault
Date: 2023-06-15T07:01:01-04:00
New Revision: 6e934f22926024bf4028d40c2f8cf33d21b05d21

URL: https://github.com/llvm/llvm-project/commit/6e934f22926024bf4028d40c2f8cf33d21b05d21
DIFF: https://github.com/llvm/llvm-project/commit/6e934f22926024bf4028d40c2f8cf33d21b05d21.diff

LOG: AMDGPU: Add baseline tests for llvm.amdgcn.exp2 folds

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll b/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
index f261931542dba..bb5ef7ea7c28f 100644
--- a/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
@@ -5912,3 +5912,298 @@ define half @test_constant_fold_log_f16_neg_denorm() {
   %val = call half @llvm.amdgcn.log.f16(half 0xH83ff)
   ret half %val
 }
+
+; --------------------------------------------------------------------
+; llvm.amdgcn.exp2
+; --------------------------------------------------------------------
+
+declare float @llvm.amdgcn.exp2.f32(float) nounwind readnone
+declare half @llvm.amdgcn.exp2.f16(half) nounwind readnone
+
+define float @test_constant_fold_exp2_f32_undef() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_undef(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float undef)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float undef)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_poison() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_poison(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float poison)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float poison)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_p0() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_p0(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_n0() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_n0(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -0.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -0.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_p1() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_p1(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 1.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 1.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_n1() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_n1(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -1.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -1.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_p2() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_p2(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 2.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 2.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_n2() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_n2(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -2.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -2.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_p4() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_p4(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 4.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 4.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_n4() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_n4(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -4.000000e+00)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -4.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_subnormal() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_subnormal(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0x380FFFFFC0000000)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0x380FFFFFC0000000)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_negsubnormal() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_negsubnormal(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0xB80FFFFFC0000000)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0xB80FFFFFC0000000)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_pinf() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_pinf(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0x7FF0000000000000)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0x7FF0000000000000)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_ninf() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_ninf(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0xFFF0000000000000)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0xFFF0000000000000)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_p10() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_p10(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 1.000000e+01)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 10.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_neg10() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_neg10(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -1.000000e+01)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -10.0)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_qnan() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_qnan(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0x7FF8000000000000)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0x7FF8000000000000)
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_snan() {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_snan(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0x7FF0000020000000)
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0x7FF0000020000000)
+  ret float %val
+}
+
+define half @test_constant_fold_exp2_f16_p0() {
+; CHECK-LABEL: @test_constant_fold_exp2_f16_p0(
+; CHECK-NEXT:    [[VAL:%.*]] = call half @llvm.amdgcn.exp2.f16(half 0xH0000)
+; CHECK-NEXT:    ret half [[VAL]]
+;
+  %val = call half @llvm.amdgcn.exp2.f16(half 0.0)
+  ret half %val
+}
+
+define half @test_constant_fold_exp2_f16_neg10() {
+; CHECK-LABEL: @test_constant_fold_exp2_f16_neg10(
+; CHECK-NEXT:    [[VAL:%.*]] = call half @llvm.amdgcn.exp2.f16(half 0xHC900)
+; CHECK-NEXT:    ret half [[VAL]]
+;
+  %val = call half @llvm.amdgcn.exp2.f16(half -10.0)
+  ret half %val
+}
+
+define float @test_constant_fold_exp2_f32_qnan_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_qnan_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0x7FF8000000000000) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0x7FF8000000000000) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_0_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_0_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0.000000e+00) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0.0) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_neg0_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_neg0_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -0.000000e+00) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -0.0) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_1_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_1_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 1.000000e+00) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 1.0) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_neg1_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_neg1_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -1.000000e+00) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -1.0) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_2_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_2_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 2.000000e+00) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 2.0) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_neg2_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_neg2_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -2.000000e+00) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -2.0) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_neg_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_neg_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float -1.000000e+01) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float -10.0) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_pinf_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_pinf_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0x7FF0000000000000) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0x7FF0000000000000) strictfp
+  ret float %val
+}
+
+define float @test_constant_fold_exp2_f32_ninf_strictfp() strictfp {
+; CHECK-LABEL: @test_constant_fold_exp2_f32_ninf_strictfp(
+; CHECK-NEXT:    [[VAL:%.*]] = call float @llvm.amdgcn.exp2.f32(float 0xFFF0000000000000) #[[ATTR16]]
+; CHECK-NEXT:    ret float [[VAL]]
+;
+  %val = call float @llvm.amdgcn.exp2.f32(float 0xFFF0000000000000) strictfp
+  ret float %val
+}
+
+define half @test_constant_fold_exp2_f16_denorm() {
+; CHECK-LABEL: @test_constant_fold_exp2_f16_denorm(
+; CHECK-NEXT:    [[VAL:%.*]] = call half @llvm.amdgcn.exp2.f16(half 0xH03FF)
+; CHECK-NEXT:    ret half [[VAL]]
+;
+  %val = call half @llvm.amdgcn.exp2.f16(half 0xH03ff)
+  ret half %val
+}
+
+define half @test_constant_fold_exp2_f16_neg_denorm() {
+; CHECK-LABEL: @test_constant_fold_exp2_f16_neg_denorm(
+; CHECK-NEXT:    [[VAL:%.*]] = call half @llvm.amdgcn.exp2.f16(half 0xH83FF)
+; CHECK-NEXT:    ret half [[VAL]]
+;
+  %val = call half @llvm.amdgcn.exp2.f16(half 0xH83ff)
+  ret half %val
+}


        


More information about the llvm-commits mailing list