From cb2e712b9e42bcbd4b91ec598f3b286c6a00a4a8 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 4 Aug 2021 18:21:34 -0400 Subject: [PATCH] pan/bi: Unit test DISCARD+FCMP fusing Signed-off-by: Alyssa Rosenzweig Part-of: --- 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); }