llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

ValueTracking: Add baseline test for nofpclass handling of amdgcn_log

Open arsenm opened this issue 1 month ago • 2 comments

arsenm avatar Dec 16 '25 15:12 arsenm

This stack of pull requests is managed by Graphite. Learn more about stacking.

arsenm avatar Dec 16 '25 15:12 arsenm

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/172491.diff

1 Files Affected:

  • (added) llvm/test/Transforms/Attributor/AMDGPU/nofpclass-amdgcn-log.ll (+277)
diff --git a/llvm/test/Transforms/Attributor/AMDGPU/nofpclass-amdgcn-log.ll b/llvm/test/Transforms/Attributor/AMDGPU/nofpclass-amdgcn-log.ll
new file mode 100644
index 0000000000000..9040030787baf
--- /dev/null
+++ b/llvm/test/Transforms/Attributor/AMDGPU/nofpclass-amdgcn-log.ll
@@ -0,0 +1,277 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -S -passes=attributor -attributor-manifest-internal < %s | FileCheck %s
+
+define half @ret_log_f16(half %arg) #1 {
+; CHECK-LABEL: define half @ret_log_f16(
+; CHECK-SAME: half [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call half @llvm.amdgcn.log.f16(half [[ARG]]) #[[ATTR7:[0-9]+]]
+; CHECK-NEXT:    ret half [[CALL]]
+;
+  %call = call half @llvm.amdgcn.log.f16(half %arg)
+  ret half %call
+}
+
+define float @ret_log_f32(float %arg) #1 {
+; CHECK-LABEL: define float @ret_log_f32(
+; CHECK-SAME: float [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noinf(float nofpclass(inf) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noinf(
+; CHECK-SAME: float nofpclass(inf) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noneg(float nofpclass(ninf nsub nnorm) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noneg(
+; CHECK-SAME: float nofpclass(ninf nsub nnorm) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(ninf nsub nnorm) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noneg_nonan(float nofpclass(nan ninf nsub nnorm) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noneg_nonan(
+; CHECK-SAME: float nofpclass(nan ninf nsub nnorm) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(nan ninf nsub nnorm) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noinf_noneg(float nofpclass(inf nsub nnorm) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noinf_noneg(
+; CHECK-SAME: float nofpclass(inf nsub nnorm) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf nsub nnorm) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noinf_noneg_nonan(float nofpclass(nan inf nsub nnorm) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noinf_noneg_nonan(
+; CHECK-SAME: float nofpclass(nan inf nsub nnorm) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(nan inf nsub nnorm) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_nopinf(float nofpclass(pinf) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_nopinf(
+; CHECK-SAME: float nofpclass(pinf) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(pinf) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noninf(float nofpclass(ninf) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noninf(
+; CHECK-SAME: float nofpclass(ninf) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(ninf) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_nonan(float nofpclass(nan) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_nonan(
+; CHECK-SAME: float nofpclass(nan) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(nan) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_nonan_noinf(float nofpclass(nan inf) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_nonan_noinf(
+; CHECK-SAME: float nofpclass(nan inf) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(nan inf) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_nonan_noinf_nozero(float nofpclass(nan inf zero) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_nonan_noinf_nozero(
+; CHECK-SAME: float nofpclass(nan inf zero) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(nan inf zero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noinf_nozero(float nofpclass(inf zero) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noinf_nozero(
+; CHECK-SAME: float nofpclass(inf zero) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf zero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_noinf_nonegzero(float nofpclass(inf nzero) %arg) #1 {
+; CHECK-LABEL: define float @ret_log_noinf_nonegzero(
+; CHECK-SAME: float nofpclass(inf nzero) [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf nzero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_positive_source(i32 %arg) #1 {
+; CHECK-LABEL: define float @ret_log_positive_source(
+; CHECK-SAME: i32 [[ARG:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[UITOFP:%.*]] = uitofp i32 [[ARG]] to float
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float [[UITOFP]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %uitofp = uitofp i32 %arg to float
+  %call = call float @llvm.amdgcn.log.f32(float %uitofp)
+  ret float %call
+}
+
+define float @ret_log_unknown_sign(float nofpclass(nan) %arg, float nofpclass(nan) %arg1) #1 {
+; CHECK-LABEL: define float @ret_log_unknown_sign(
+; CHECK-SAME: float nofpclass(nan) [[ARG:%.*]], float nofpclass(nan) [[ARG1:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:    [[UNKNOWN_SIGN_NOT_NAN:%.*]] = fmul nnan float [[ARG]], [[ARG1]]
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float [[UNKNOWN_SIGN_NOT_NAN]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %unknown.sign.not.nan = fmul nnan float %arg, %arg1
+  %call = call float @llvm.amdgcn.log.f32(float %unknown.sign.not.nan)
+  ret float %call
+}
+
+define float @ret_log_daz_noinf_nozero(float nofpclass(inf zero) %arg) #2 {
+; CHECK-LABEL: define float @ret_log_daz_noinf_nozero(
+; CHECK-SAME: float nofpclass(inf zero) [[ARG:%.*]]) #[[ATTR1:[0-9]+]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf zero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define <2 x float> @ret_log_daz_noinf_nozero_v2f32(<2 x float> nofpclass(inf zero) %arg) #2 {
+; CHECK-LABEL: define nofpclass(pinf) <2 x float> @ret_log_daz_noinf_nozero_v2f32(
+; CHECK-SAME: <2 x float> nofpclass(inf zero) [[ARG:%.*]]) #[[ATTR1]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call nofpclass(pinf) <2 x float> @llvm.log.v2f32(<2 x float> nofpclass(inf zero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret <2 x float> [[CALL]]
+;
+  %call = call <2 x float> @llvm.log.v2f32(<2 x float> %arg)
+  ret <2 x float> %call
+}
+
+define float @ret_log_daz_noinf_nonegzero(float nofpclass(inf nzero) %arg) #2 {
+; CHECK-LABEL: define float @ret_log_daz_noinf_nonegzero(
+; CHECK-SAME: float nofpclass(inf nzero) [[ARG:%.*]]) #[[ATTR1]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf nzero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_dynamic_noinf_nozero(float nofpclass(inf zero) %arg) #3 {
+; CHECK-LABEL: define float @ret_log_dynamic_noinf_nozero(
+; CHECK-SAME: float nofpclass(inf zero) [[ARG:%.*]]) #[[ATTR2:[0-9]+]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf zero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_dynamic_noinf_nonegzero(float nofpclass(inf nzero) %arg) #3 {
+; CHECK-LABEL: define float @ret_log_dynamic_noinf_nonegzero(
+; CHECK-SAME: float nofpclass(inf nzero) [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf nzero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_ftz_noinf_nonegzero(float nofpclass(inf nzero) %arg) #4 {
+; CHECK-LABEL: define float @ret_log_ftz_noinf_nonegzero(
+; CHECK-SAME: float nofpclass(inf nzero) [[ARG:%.*]]) #[[ATTR3:[0-9]+]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf nzero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_ftz_dynamic_noinf_nonegzero(float nofpclass(inf nzero) %arg) #5 {
+; CHECK-LABEL: define float @ret_log_ftz_dynamic_noinf_nonegzero(
+; CHECK-SAME: float nofpclass(inf nzero) [[ARG:%.*]]) #[[ATTR4:[0-9]+]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf nzero) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_dynamic_noinf_nozero_nosub(float nofpclass(inf zero sub) %arg) #3 {
+; CHECK-LABEL: define float @ret_log_dynamic_noinf_nozero_nosub(
+; CHECK-SAME: float nofpclass(inf zero sub) [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf zero sub) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_dynamic_noinf_nopzero_nopsub(float nofpclass(inf pzero psub) %arg) #3 {
+; CHECK-LABEL: define float @ret_log_dynamic_noinf_nopzero_nopsub(
+; CHECK-SAME: float nofpclass(inf pzero psub) [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf pzero psub) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+define float @ret_log_dynamic_noinf_nonzero_nonsub(float nofpclass(inf nzero nsub) %arg) #3 {
+; CHECK-LABEL: define float @ret_log_dynamic_noinf_nonzero_nonsub(
+; CHECK-SAME: float nofpclass(inf nzero nsub) [[ARG:%.*]]) #[[ATTR2]] {
+; CHECK-NEXT:    [[CALL:%.*]] = call float @llvm.amdgcn.log.f32(float nofpclass(inf nzero nsub) [[ARG]]) #[[ATTR7]]
+; CHECK-NEXT:    ret float [[CALL]]
+;
+  %call = call float @llvm.amdgcn.log.f32(float %arg)
+  ret float %call
+}
+
+declare half @llvm.amdgcn.log.f16(half) #0
+declare float @llvm.amdgcn.log.f32(float) #0
+
+attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+attributes #1 = { "denormal-fp-math"="ieee,ieee" }
+attributes #2 = { "denormal-fp-math"="ieee,preserve-sign" }
+attributes #3 = { "denormal-fp-math"="ieee,dynamic" }
+attributes #4 = { "denormal-fp-math"="preserve-sign,ieee" }
+attributes #5 = { "denormal-fp-math"="dynamic,ieee" }
+attributes #6 = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }

llvmbot avatar Dec 16 '25 15:12 llvmbot

LLVM Buildbot has detected a new failure on builder ml-opt-dev-x86-64 running on ml-opt-dev-x86-64-b2 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/30797

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/MLRegAlloc/dev-mode-log-2-fcts.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 6
/b/ml-opt-dev-x86-64-b1/build/bin/llc -mtriple=x86_64-linux-unknown -regalloc=greedy -regalloc-enable-advisor=development    -regalloc-training-log=/b/ml-opt-dev-x86-64-b1/build/test/CodeGen/MLRegAlloc/Output/dev-mode-log-2-fcts.ll.tmp1 < /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/MLRegAlloc/dev-mode-log-2-fcts.ll
# executed command: /b/ml-opt-dev-x86-64-b1/build/bin/llc -mtriple=x86_64-linux-unknown -regalloc=greedy -regalloc-enable-advisor=development -regalloc-training-log=/b/ml-opt-dev-x86-64-b1/build/test/CodeGen/MLRegAlloc/Output/dev-mode-log-2-fcts.ll.tmp1
# .---command stdout------------
# | 	.file	"<stdin>"
# | 	.section	.text.unlikely.,"ax",@progbits
# | 	.globl	f1                              # -- Begin function f1
# | 	.p2align	4
# | 	.type	f1,@function
# | f1:                                     # @f1
# | 	.cfi_startproc
# | # %bb.0:
# | 	pushq	%r14
# | 	.cfi_def_cfa_offset 16
# | 	pushq	%rbx
# | 	.cfi_def_cfa_offset 24
# | 	pushq	%rax
# | 	.cfi_def_cfa_offset 32
# | 	.cfi_offset %rbx, -24
# | 	.cfi_offset %r14, -16
# | 	movq	%rdx, %rbx
# | 	movq	%rdi, %r14
# | 	addq	%rsi, %r14
# | 	callq	f@PLT
# | 	movq	%r14, (%rbx)
# | 	addq	$8, %rsp
# | 	.cfi_def_cfa_offset 24
# | 	popq	%rbx
# | 	.cfi_def_cfa_offset 16
# | 	popq	%r14
# | 	.cfi_def_cfa_offset 8
# | 	retq
# | .Lfunc_end0:
# | 	.size	f1, .Lfunc_end0-f1
# | 	.cfi_endproc
# |                                         # -- End function
# | 	.section	.text.hot.,"ax",@progbits
# | 	.globl	f2                              # -- Begin function f2
# | 	.p2align	4
# | 	.type	f2,@function
# | f2:                                     # @f2
# | 	.cfi_startproc
# | # %bb.0:
# | 	addq	%rsi, %rdi
# | 	movq	%rdi, (%rdx)
...

llvm-ci avatar Dec 17 '25 21:12 llvm-ci