-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC][InstSimplify] Refactor fminmax-folds.ll test #160504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC][InstSimplify] Refactor fminmax-folds.ll test #160504
Conversation
Refactor all the tests in fminmax-folds.ll so that they are grouped by optimization, rather than by intrinsic. Instead of calling 1 intrinsic per function, each function now tests all 6 variants of the intrinsic. Results are stored to named pointers to maintain readability in this more compact form. This makes it much easier to compare the outputs from each intrinsic, rather than having them scattered in different functions in different parts of the file. It is also much more compact, so despite adding >50% more tests, the file is ~500 lines shorter. The tests added include: * Adding maximumnum and minimumnum everywhere (currently not optimized, but added as a baseline for future optimizations in llvm#139581). * Adding separate tests for SNaN and QNaN (as a baseline for correctness improvements in llvm#139581) * Adding tests for scalable vectors * Increasing the variety of types used in various tests by using more f16, f64, and vector types in tests. The only coverage removed is for tests with undef (only poison is now tested for). Overall, this refactor should increase coverage, improve readability with more comments and clear section headers, and make the tests much more compact and easier to review in llvm#139581 by providing a clear baseline for each intrinsic's current behaviour.
@llvm/pr-subscribers-llvm-transforms Author: Lewis Crawford (LewisCrawford) ChangesRefactor all the tests in Instead of calling 1 intrinsic per function, each function now tests all 6 variants of the intrinsic. Results are stored to named pointers to maintain readability in this more compact form. This makes it much easier to compare the outputs from each intrinsic, rather than having them scattered in different functions in different parts of the file. It is also much more compact, so despite adding >50% more tests, the file is ~500 lines shorter. The tests added include:
The only coverage removed is for tests with undef (only poison is now tested for). Overall, this refactor should increase coverage, improve readability with more comments and clear section headers, and make the tests much more compact and easier to review in #139581 by providing a clear baseline for each intrinsic's current behaviour. Patch is 104.02 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/160504.diff 1 Files Affected:
diff --git a/llvm/test/Transforms/InstSimplify/fminmax-folds.ll b/llvm/test/Transforms/InstSimplify/fminmax-folds.ll
index fff6cfd8a3b4b..26b51146057e9 100644
--- a/llvm/test/Transforms/InstSimplify/fminmax-folds.ll
+++ b/llvm/test/Transforms/InstSimplify/fminmax-folds.ll
@@ -1,1388 +1,854 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
-declare half @llvm.minimum.f16(half, half)
-declare half @llvm.maximum.f16(half, half)
-
-declare float @llvm.minnum.f32(float, float)
-declare float @llvm.maxnum.f32(float, float)
-declare float @llvm.minimum.f32(float, float)
-declare float @llvm.maximum.f32(float, float)
-declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>)
-declare <2 x float> @llvm.maxnum.v2f32(<2 x float>, <2 x float>)
-declare <2 x float> @llvm.minimum.v2f32(<2 x float>, <2 x float>)
-declare <2 x float> @llvm.maximum.v2f32(<2 x float>, <2 x float>)
-
-declare double @llvm.minnum.f64(double, double)
-declare double @llvm.maxnum.f64(double, double)
-declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>)
-declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>)
-declare double @llvm.minimum.f64(double, double)
-declare double @llvm.maximum.f64(double, double)
-declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>)
-declare <2 x double> @llvm.maximum.v2f64(<2 x double>, <2 x double>)
-
-define float @test_minnum_const_nan(float %x) {
-; CHECK-LABEL: @test_minnum_const_nan(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call float @llvm.minnum.f32(float %x, float 0x7fff000000000000)
- ret float %r
-}
-
-define float @test_maxnum_const_nan(float %x) {
-; CHECK-LABEL: @test_maxnum_const_nan(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call float @llvm.maxnum.f32(float %x, float 0x7fff000000000000)
- ret float %r
-}
-
-define float @test_maximum_const_nan(float %x) {
-; CHECK-LABEL: @test_maximum_const_nan(
-; CHECK-NEXT: ret float 0x7FFF000000000000
-;
- %r = call float @llvm.maximum.f32(float %x, float 0x7fff000000000000)
- ret float %r
-}
-
-define float @test_minimum_const_nan(float %x) {
-; CHECK-LABEL: @test_minimum_const_nan(
-; CHECK-NEXT: ret float 0x7FFF000000000000
-;
- %r = call float @llvm.minimum.f32(float %x, float 0x7fff000000000000)
- ret float %r
-}
-
-define float @test_minnum_const_inf(float %x) {
-; CHECK-LABEL: @test_minnum_const_inf(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0x7FF0000000000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.minnum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_maxnum_const_inf(float %x) {
-; CHECK-LABEL: @test_maxnum_const_inf(
-; CHECK-NEXT: ret float 0x7FF0000000000000
-;
- %r = call float @llvm.maxnum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_maximum_const_inf(float %x) {
-; CHECK-LABEL: @test_maximum_const_inf(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 0x7FF0000000000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.maximum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_minimum_const_inf(float %x) {
-; CHECK-LABEL: @test_minimum_const_inf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call float @llvm.minimum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_minnum_const_neg_inf(float %x) {
-; CHECK-LABEL: @test_minnum_const_neg_inf(
-; CHECK-NEXT: ret float 0xFFF0000000000000
-;
- %r = call float @llvm.minnum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_maxnum_const_neg_inf(float %x) {
-; CHECK-LABEL: @test_maxnum_const_neg_inf(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 0xFFF0000000000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.maxnum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_maximum_const_neg_inf(float %x) {
-; CHECK-LABEL: @test_maximum_const_neg_inf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call float @llvm.maximum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_minimum_const_neg_inf(float %x) {
-; CHECK-LABEL: @test_minimum_const_neg_inf(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0xFFF0000000000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.minimum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_minnum_const_inf_nnan(float %x) {
-; CHECK-LABEL: @test_minnum_const_inf_nnan(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan float @llvm.minnum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_maxnum_const_inf_nnan(float %x) {
-; CHECK-LABEL: @test_maxnum_const_inf_nnan(
-; CHECK-NEXT: ret float 0x7FF0000000000000
-;
- %r = call nnan float @llvm.maxnum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_maximum_const_inf_nnan(float %x) {
-; CHECK-LABEL: @test_maximum_const_inf_nnan(
-; CHECK-NEXT: ret float 0x7FF0000000000000
-;
- %r = call nnan float @llvm.maximum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_minimum_const_inf_nnan(float %x) {
-; CHECK-LABEL: @test_minimum_const_inf_nnan(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan float @llvm.minimum.f32(float %x, float 0x7ff0000000000000)
- ret float %r
-}
-
-define float @test_minnum_const_inf_nnan_comm(float %x) {
-; CHECK-LABEL: @test_minnum_const_inf_nnan_comm(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan float @llvm.minnum.f32(float 0x7ff0000000000000, float %x)
- ret float %r
-}
-
-define float @test_maxnum_const_inf_nnan_comm(float %x) {
-; CHECK-LABEL: @test_maxnum_const_inf_nnan_comm(
-; CHECK-NEXT: ret float 0x7FF0000000000000
-;
- %r = call nnan float @llvm.maxnum.f32(float 0x7ff0000000000000, float %x)
- ret float %r
-}
-
-define float @test_maximum_const_inf_nnan_comm(float %x) {
-; CHECK-LABEL: @test_maximum_const_inf_nnan_comm(
-; CHECK-NEXT: ret float 0x7FF0000000000000
-;
- %r = call nnan float @llvm.maximum.f32(float 0x7ff0000000000000, float %x)
- ret float %r
-}
-
-define float @test_minimum_const_inf_nnan_comm(float %x) {
-; CHECK-LABEL: @test_minimum_const_inf_nnan_comm(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan float @llvm.minimum.f32(float 0x7ff0000000000000, float %x)
- ret float %r
-}
-
-define <2 x float> @test_minnum_const_inf_nnan_comm_vec(<2 x float> %x) {
-; CHECK-LABEL: @test_minnum_const_inf_nnan_comm_vec(
-; CHECK-NEXT: ret <2 x float> [[X:%.*]]
-;
- %r = call nnan <2 x float> @llvm.minnum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
- ret <2 x float> %r
-}
-
-define <2 x float> @test_maxnum_const_inf_nnan_comm_vec(<2 x float> %x) {
-; CHECK-LABEL: @test_maxnum_const_inf_nnan_comm_vec(
-; CHECK-NEXT: ret <2 x float> splat (float 0x7FF0000000000000)
-;
- %r = call nnan <2 x float> @llvm.maxnum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
- ret <2 x float> %r
-}
-
-define <2 x float> @test_maximum_const_inf_nnan_comm_vec(<2 x float> %x) {
-; CHECK-LABEL: @test_maximum_const_inf_nnan_comm_vec(
-; CHECK-NEXT: ret <2 x float> splat (float 0x7FF0000000000000)
-;
- %r = call nnan <2 x float> @llvm.maximum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
- ret <2 x float> %r
-}
-
-define <2 x float> @test_minimum_const_inf_nnan_comm_vec(<2 x float> %x) {
-; CHECK-LABEL: @test_minimum_const_inf_nnan_comm_vec(
-; CHECK-NEXT: ret <2 x float> [[X:%.*]]
-;
- %r = call nnan <2 x float> @llvm.minimum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
- ret <2 x float> %r
-}
-
-define float @test_minnum_const_neg_inf_nnan(float %x) {
-; CHECK-LABEL: @test_minnum_const_neg_inf_nnan(
-; CHECK-NEXT: ret float 0xFFF0000000000000
-;
- %r = call nnan float @llvm.minnum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_maxnum_const_neg_inf_nnan(float %x) {
-; CHECK-LABEL: @test_maxnum_const_neg_inf_nnan(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan float @llvm.maxnum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_maximum_const_neg_inf_nnan(float %x) {
-; CHECK-LABEL: @test_maximum_const_neg_inf_nnan(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan float @llvm.maximum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_minimum_const_neg_inf_nnan(float %x) {
-; CHECK-LABEL: @test_minimum_const_neg_inf_nnan(
-; CHECK-NEXT: ret float 0xFFF0000000000000
-;
- %r = call nnan float @llvm.minimum.f32(float %x, float 0xfff0000000000000)
- ret float %r
-}
-
-define float @test_minnum_const_max(float %x) {
-; CHECK-LABEL: @test_minnum_const_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.minnum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_maxnum_const_max(float %x) {
-; CHECK-LABEL: @test_maxnum_const_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.maxnum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_maximum_const_max(float %x) {
-; CHECK-LABEL: @test_maximum_const_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.maximum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_minimum_const_max(float %x) {
-; CHECK-LABEL: @test_minimum_const_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.minimum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_minnum_const_neg_max(float %x) {
-; CHECK-LABEL: @test_minnum_const_neg_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.minnum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_maxnum_const_neg_max(float %x) {
-; CHECK-LABEL: @test_maxnum_const_neg_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.maxnum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_maximum_const_neg_max(float %x) {
-; CHECK-LABEL: @test_maximum_const_neg_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.maximum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_minimum_const_neg_max(float %x) {
-; CHECK-LABEL: @test_minimum_const_neg_max(
-; CHECK-NEXT: [[R:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call float @llvm.minimum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_minnum_const_max_ninf(float %x) {
-; CHECK-LABEL: @test_minnum_const_max_ninf(
-; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.minnum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call ninf float @llvm.minnum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_maxnum_const_max_ninf(float %x) {
-; CHECK-LABEL: @test_maxnum_const_max_ninf(
-; CHECK-NEXT: ret float 0x47EFFFFFE0000000
-;
- %r = call ninf float @llvm.maxnum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_maximum_const_max_ninf(float %x) {
-; CHECK-LABEL: @test_maximum_const_max_ninf(
-; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.maximum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call ninf float @llvm.maximum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_minimum_const_max_ninf(float %x) {
-; CHECK-LABEL: @test_minimum_const_max_ninf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call ninf float @llvm.minimum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_minnum_const_neg_max_ninf(float %x) {
-; CHECK-LABEL: @test_minnum_const_neg_max_ninf(
-; CHECK-NEXT: ret float 0xC7EFFFFFE0000000
-;
- %r = call ninf float @llvm.minnum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_maxnum_const_neg_max_ninf(float %x) {
-; CHECK-LABEL: @test_maxnum_const_neg_max_ninf(
-; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.maxnum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call ninf float @llvm.maxnum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_maximum_const_neg_max_ninf(float %x) {
-; CHECK-LABEL: @test_maximum_const_neg_max_ninf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call ninf float @llvm.maximum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_minimum_const_neg_max_ninf(float %x) {
-; CHECK-LABEL: @test_minimum_const_neg_max_ninf(
-; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.minimum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
-; CHECK-NEXT: ret float [[R]]
-;
- %r = call ninf float @llvm.minimum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_minnum_const_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_minnum_const_max_nnan_ninf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan ninf float @llvm.minnum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_maxnum_const_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_maxnum_const_max_nnan_ninf(
-; CHECK-NEXT: ret float 0x47EFFFFFE0000000
-;
- %r = call nnan ninf float @llvm.maxnum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_maximum_const_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_maximum_const_max_nnan_ninf(
-; CHECK-NEXT: ret float 0x47EFFFFFE0000000
-;
- %r = call nnan ninf float @llvm.maximum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_minimum_const_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_minimum_const_max_nnan_ninf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan ninf float @llvm.minimum.f32(float %x, float 0x47efffffe0000000)
- ret float %r
-}
-
-define float @test_minnum_const_neg_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_minnum_const_neg_max_nnan_ninf(
-; CHECK-NEXT: ret float 0xC7EFFFFFE0000000
-;
- %r = call nnan ninf float @llvm.minnum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_maxnum_const_neg_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_maxnum_const_neg_max_nnan_ninf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan ninf float @llvm.maxnum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_maximum_const_neg_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_maximum_const_neg_max_nnan_ninf(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %r = call nnan ninf float @llvm.maximum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-define float @test_minimum_const_neg_max_nnan_ninf(float %x) {
-; CHECK-LABEL: @test_minimum_const_neg_max_nnan_ninf(
-; CHECK-NEXT: ret float 0xC7EFFFFFE0000000
-;
- %r = call nnan ninf float @llvm.minimum.f32(float %x, float 0xc7efffffe0000000)
- ret float %r
-}
-
-; From the LangRef for minnum/maxnum:
-; "If either operand is a NaN, returns the other non-NaN operand."
-
-define double @maxnum_nan_op0(double %x) {
-; CHECK-LABEL: @maxnum_nan_op0(
-; CHECK-NEXT: ret double [[X:%.*]]
-;
- %r = call double @llvm.maxnum.f64(double 0x7ff8000000000000, double %x)
- ret double %r
-}
-
-define double @maxnum_nan_op1(double %x) {
-; CHECK-LABEL: @maxnum_nan_op1(
-; CHECK-NEXT: ret double [[X:%.*]]
-;
- %r = call double @llvm.maxnum.f64(double %x, double 0x7ff800000000dead)
- ret double %r
-}
-
-define double @minnum_nan_op0(double %x) {
-; CHECK-LABEL: @minnum_nan_op0(
-; CHECK-NEXT: ret double [[X:%.*]]
-;
- %r = call double @llvm.minnum.f64(double 0x7ff8000dead00000, double %x)
- ret double %r
-}
-
-define double @minnum_nan_op1(double %x) {
-; CHECK-LABEL: @minnum_nan_op1(
-; CHECK-NEXT: ret double [[X:%.*]]
-;
- %r = call double @llvm.minnum.f64(double %x, double 0x7ff800dead00dead)
- ret double %r
-}
-
-define <2 x double> @maxnum_nan_op0_vec(<2 x double> %x) {
-; CHECK-LABEL: @maxnum_nan_op0_vec(
-; CHECK-NEXT: ret <2 x double> [[X:%.*]]
-;
- %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> <double 0x7ff8000000000000, double poison>, <2 x double> %x)
- ret <2 x double> %r
-}
-
-define <2 x double> @maxnum_nan_op1_vec(<2 x double> %x) {
-; CHECK-LABEL: @maxnum_nan_op1_vec(
-; CHECK-NEXT: ret <2 x double> [[X:%.*]]
-;
- %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800000000dead, double 0x7ff8ffffffffffff>)
- ret <2 x double> %r
-}
-
-define <2 x double> @minnum_nan_op0_vec(<2 x double> %x) {
-; CHECK-LABEL: @minnum_nan_op0_vec(
-; CHECK-NEXT: ret <2 x double> [[X:%.*]]
-;
- %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> <double poison, double 0x7ff8000dead00000>, <2 x double> %x)
- ret <2 x double> %r
-}
-
-define <2 x double> @minnum_nan_op1_vec(<2 x double> %x) {
-; CHECK-LABEL: @minnum_nan_op1_vec(
-; CHECK-NEXT: ret <2 x double> [[X:%.*]]
-;
- %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800dead00dead, double 0x7ff800dead00dead>)
- ret <2 x double> %r
-}
-
-define float @maxnum_undef_op1(float %x) {
-; CHECK-LABEL: @maxnum_undef_op1(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.maxnum.f32(float %x, float undef)
- ret float %val
-}
-
-define float @maxnum_poison_op1(float %x) {
-; CHECK-LABEL: @maxnum_poison_op1(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.maxnum.f32(float %x, float poison)
- ret float %val
-}
-
-define float @maxnum_undef_op0(float %x) {
-; CHECK-LABEL: @maxnum_undef_op0(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.maxnum.f32(float undef, float %x)
- ret float %val
-}
-
-define float @maxnum_poison_op0(float %x) {
-; CHECK-LABEL: @maxnum_poison_op0(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.maxnum.f32(float poison, float %x)
- ret float %val
-}
-
-define float @minnum_undef_op1(float %x) {
-; CHECK-LABEL: @minnum_undef_op1(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.minnum.f32(float %x, float undef)
- ret float %val
-}
-
-define float @minnum_poison_op1(float %x) {
-; CHECK-LABEL: @minnum_poison_op1(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.minnum.f32(float %x, float poison)
- ret float %val
-}
-
-define float @minnum_undef_op0(float %x) {
-; CHECK-LABEL: @minnum_undef_op0(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.minnum.f32(float undef, float %x)
- ret float %val
-}
-
-define float @minnum_poison_op0(float %x) {
-; CHECK-LABEL: @minnum_poison_op0(
-; CHECK-NEXT: ret float [[X:%.*]]
-;
- %val = call float @llvm.minnum.f32(float poison, float %x)
- ret float %val
-}
-
-define float @minnum_undef_undef(float %x) {
-; CHECK-LABEL: @minnum_undef_undef(
-; CHECK-NEXT: ret float undef
-;
- %val = call float @llvm.minnum.f32(float undef, float undef)
- ret float %val
-}
-
-define float @minnum_poison_undef(float %x) {
-; CHECK-LABEL: @minnum_poison_undef(
-; CHECK-NEXT: ret float undef
-;
- %val = call float @llvm.minnum.f32(float poison, float undef)
- ret float %val
-}
-
-define float @minnum_undef_poison(float %x) {
-; CHECK-LABEL: @minnum_undef_poison(
-; CHECK-NEXT: ret float poison
-;
- %val = call float @llvm.minnum.f32(float undef, flo...
[truncated]
|
Adding @arsenm and @Artem-B as reviewers too, since this impacts the tests added in #139581 Currently #139581 adds ~1800 lines of tests (to cover maximumnum + QNaN vs SNaN). With this refactor, ~90% of those new tests will already have baselines included in the new ~800 line version of the file, so it will make the diff in #139581 much smaller and easier to read. |
Merge branch 'main' into instsimplify_maximumnum Replace the old fminmax-folds.ll test with the newly refactored version from llvm#160504. These tests will not pass yet with the new branch, but this provides a clean baseline. Conflicts: llvm/test/Transforms/InstSimplify/fminmax-folds.ll
* main: (502 commits) GlobalISel: Adjust insert point when expanding G_[SU]DIVREM (llvm#160683) [LV] Add coverage for fixing-up scalar resume values (llvm#160492) AMDGPU: Convert wave_any test to use update_mc_test_checks [LV] Add partial reduction tests multiplying extend with constants. Revert "[MLIR] Implement remark emitting policies in MLIR" (llvm#160681) [NFC][InstSimplify] Refactor fminmax-folds.ll test (llvm#160504) [LoongArch] Pre-commit tests for [x]vldi instructions with special constant splats (llvm#159228) [BOLT] Fix dwarf5-dwoid-no-dwoname.s (llvm#160676) [lldb][test] Refactor and expand TestMemoryRegionDirtyPages.py (llvm#156035) [gn build] Port 833d5f0 AMDGPU: Ensure both wavesize features are not set (llvm#159234) [LoopInterchange] Bail out when finding a dependency with all `*` elements (llvm#149049) [libc++] Avoid constructing additional objects when using map::at (llvm#157866) [lldb][test] Make hex prefix optional in DWARF union types test [X86] Add missing prefixes to trunc-sat tests (llvm#160662) [AMDGPU] Fix vector legalization for bf16 valu ops (llvm#158439) [LoongArch][NFC] Pre-commit tests for `[x]vadda.{b/h/w/d}` [mlir][tosa] Relax constraint on matmul verifier requiring equal operand types (llvm#155799) [clang][Sema] Accept gnu format attributes (llvm#160255) [LoongArch][NFC] Add tests for element extraction from binary add operation (llvm#159725) ...
Refactor all the tests in `fminmax-folds.ll` so that they are grouped by optimization, rather than by intrinsic. Instead of calling 1 intrinsic per function, each function now tests all 6 variants of the intrinsic. Results are stored to named pointers to maintain readability in this more compact form. This makes it much easier to compare the outputs from each intrinsic, rather than having them scattered in different functions in different parts of the file. It is also much more compact, so despite adding >50% more tests, the file is ~500 lines shorter. The tests added include: * Adding `maximumnum` and `minimumnum` everywhere (currently not optimized, but added as a baseline for future optimizations in llvm#139581). * Adding separate tests for SNaN and QNaN (as a baseline for correctness improvements in llvm#139581 ) * Adding tests for scalable vectors * Increasing the variety of types used in various tests by using more f16, f64, and vector types in tests. The only coverage removed is for tests with undef (only poison is now tested for). Overall, this refactor should increase coverage, improve readability with more comments and clear section headers, and make the tests much more compact and easier to review in llvm#139581 by providing a clear baseline for each intrinsic's current behaviour.
Refactor all the tests in
fminmax-folds.ll
so that they are grouped by optimization, rather than by intrinsic.Instead of calling 1 intrinsic per function, each function now tests all 6 variants of the intrinsic. Results are stored to named pointers to maintain readability in this more compact form. This makes it much easier to compare the outputs from each intrinsic, rather than having them scattered in different functions in different parts of the file. It is also much more compact, so despite adding >50% more tests, the file is ~500 lines shorter.
The tests added include:
maximumnum
andminimumnum
everywhere (currently not optimized, but added as a baseline for future optimizations in [InstSimplify] Optimize maximumnum and minimumnum #139581).The only coverage removed is for tests with undef (only poison is now tested for).
Overall, this refactor should increase coverage, improve readability with more comments and clear section headers, and make the tests much more compact and easier to review in #139581 by providing a clear baseline for each intrinsic's current behaviour.