Mesa (main): pan/bi: Unit test DISCARD+FCMP fusing

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 11 19:20:00 UTC 2021


Module: Mesa
Branch: main
Commit: cb2e712b9e42bcbd4b91ec598f3b286c6a00a4a8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb2e712b9e42bcbd4b91ec598f3b286c6a00a4a8

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Wed Aug  4 18:21:34 2021 -0400

pan/bi: Unit test DISCARD+FCMP fusing

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12205>

---

 src/panfrost/bifrost/test/test-optimizer.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/panfrost/bifrost/test/test-optimizer.c b/src/panfrost/bifrost/test/test-optimizer.c
index 6fc94609df3..6d70acdfc4d 100644
--- a/src/panfrost/bifrost/test/test-optimizer.c
+++ b/src/panfrost/bifrost/test/test-optimizer.c
@@ -237,6 +237,32 @@ main(int argc, const char **argv)
       I->clamp = BI_CLAMP_CLAMP_0_1;
    });
 
+   /* Check that we fuse comparisons with DISCARD */
+
+   CASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_F1)),
+        bi_discard_f32(b, x, y, BI_CMPF_LE));
+
+   CASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_NE, BI_RESULT_TYPE_I1)),
+        bi_discard_f32(b, x, y, BI_CMPF_NE));
+
+   CASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_EQ, BI_RESULT_TYPE_M1)),
+        bi_discard_f32(b, x, y, BI_CMPF_EQ));
+
+   for (unsigned h = 0; h < 2; ++h) {
+      CASE(bi_discard_b32(b, bi_half(bi_fcmp_v2f16(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_F1), h)),
+           bi_discard_f32(b, bi_half(x, h), bi_half(y, h), BI_CMPF_LE));
+
+      CASE(bi_discard_b32(b, bi_half(bi_fcmp_v2f16(b, x, y, BI_CMPF_NE, BI_RESULT_TYPE_I1), h)),
+           bi_discard_f32(b, bi_half(x, h), bi_half(y, h), BI_CMPF_NE));
+
+      CASE(bi_discard_b32(b, bi_half(bi_fcmp_v2f16(b, x, y, BI_CMPF_EQ, BI_RESULT_TYPE_M1), h)),
+           bi_discard_f32(b, bi_half(x, h), bi_half(y, h), BI_CMPF_EQ));
+   }
+
+   /* Refuse to fuse special comparisons */
+   NEGCASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_GTLT, BI_RESULT_TYPE_F1)));
+   NEGCASE(bi_discard_b32(b, bi_fcmp_f32(b, x, y, BI_CMPF_TOTAL, BI_RESULT_TYPE_F1)));
+
    ralloc_free(ralloc_ctx);
    TEST_END(nr_pass, nr_fail);
 }



More information about the mesa-commit mailing list