From 01ba3460a99d5488ac93ef126714a97808df7ad9 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 6 Jan 2022 16:43:07 -0500 Subject: [PATCH] pan/bi: Test CMP result_type optimization Add unit tests ensuring the optimization applies in all the cases we care about, as functional integration tests (CTS and Piglit) won't test this. Also add unit tests for a few cases where we specifically cannot fuse, in case these cases are missed by the tests. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/test/test-optimizer.cpp | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/panfrost/bifrost/test/test-optimizer.cpp b/src/panfrost/bifrost/test/test-optimizer.cpp index 50593ea25f0..03d3f8e34fb 100644 --- a/src/panfrost/bifrost/test/test-optimizer.cpp +++ b/src/panfrost/bifrost/test/test-optimizer.cpp @@ -352,3 +352,72 @@ TEST_F(Optimizer, DoNotFuseSpecialComparisons) 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))); } + +TEST_F(Optimizer, FuseResultType) +{ + CASE(bi_mux_i32_to(b, reg, bi_imm_f32(0.0), bi_imm_f32(1.0), + bi_fcmp_f32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_fcmp_f32_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_F1)); + + CASE(bi_mux_i32_to(b, reg, bi_imm_f32(0.0), bi_imm_f32(1.0), + bi_fcmp_f32(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_fcmp_f32_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_F1)); + + CASE(bi_mux_i32_to(b, reg, bi_imm_u32(0), bi_imm_u32(1), + bi_fcmp_f32(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_fcmp_f32_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_I1)); + + CASE(bi_mux_v2i16_to(b, reg, bi_imm_f16(0.0), bi_imm_f16(1.0), + bi_fcmp_v2f16(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_fcmp_v2f16_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_F1)); + + CASE(bi_mux_v2i16_to(b, reg, bi_imm_u16(0), bi_imm_u16(1), + bi_fcmp_v2f16(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_fcmp_v2f16_to(b, reg, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_I1)); + + CASE(bi_mux_i32_to(b, reg, bi_imm_u32(0), bi_imm_u32(1), + bi_icmp_u32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_icmp_u32_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1)); + + CASE(bi_mux_v2i16_to(b, reg, bi_imm_u16(0), bi_imm_u16(1), + bi_icmp_v2u16(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_icmp_v2u16_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1)); + + CASE(bi_mux_v4i8_to(b, reg, bi_imm_u8(0), bi_imm_u8(1), + bi_icmp_v4u8(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_icmp_v4u8_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1)); + + CASE(bi_mux_i32_to(b, reg, bi_imm_u32(0), bi_imm_u32(1), + bi_icmp_s32(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_icmp_s32_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1)); + + CASE(bi_mux_v2i16_to(b, reg, bi_imm_u16(0), bi_imm_u16(1), + bi_icmp_v2s16(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_icmp_v2s16_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1)); + + CASE(bi_mux_v4i8_to(b, reg, bi_imm_u8(0), bi_imm_u8(1), + bi_icmp_v4s8(b, x, y, BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO), + bi_icmp_v4s8_to(b, reg, x, y, BI_CMPF_LE, BI_RESULT_TYPE_I1)); +} + +TEST_F(Optimizer, DoNotFuseMixedSizeResultType) +{ + NEGCASE(bi_mux_i32_to(b, reg, bi_imm_f32(0.0), bi_imm_f32(1.0), + bi_fcmp_v2f16(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO)); + + NEGCASE(bi_mux_v2i16_to(b, reg, bi_imm_f16(0.0), bi_imm_f16(1.0), + bi_fcmp_f32(b, bi_abs(x), bi_neg(y), BI_CMPF_LE, BI_RESULT_TYPE_M1), + BI_MUX_INT_ZERO)); +}