From 8f4b3c749ed482a365671fce51e00fd3d6122a73 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 17 Feb 2022 19:40:03 -0500 Subject: [PATCH] pan/bi: Test avoiding FADD.v2f16 hazards in scheduler There are many of them, and integration testing of the scheduler won't hit every case. Add targeted unit tests for the various scheduling hazards of this funny instruction. Signed-off-by: Alyssa Rosenzweig Part-of: --- .../test/test-scheduler-predicates.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/panfrost/bifrost/test/test-scheduler-predicates.cpp b/src/panfrost/bifrost/test/test-scheduler-predicates.cpp index f43754d29ca..93aaf7fe196 100644 --- a/src/panfrost/bifrost/test/test-scheduler-predicates.cpp +++ b/src/panfrost/bifrost/test/test-scheduler-predicates.cpp @@ -107,3 +107,45 @@ TEST_F(SchedulerPredicates, RestrictionsOnModifiersOfSameCycleTemporaries) } } } + +TEST_F(SchedulerPredicates, RestrictionsOnFAddV2F16) +{ + bi_index x = bi_register(0); + bi_index y = bi_register(1); + + /* Basic */ + bi_instr *fadd = bi_fadd_v2f16_to(b, TMP(), x, x, BI_ROUND_NONE); + + ASSERT_TRUE(bi_can_fma(fadd)); + ASSERT_TRUE(bi_can_add(fadd)); + + /* With imbalanced abs */ + fadd->src[0].abs = true; + + ASSERT_TRUE(bi_can_fma(fadd)); + ASSERT_TRUE(bi_can_add(fadd)); + + /* With equal abs */ + fadd->src[1].abs = true; + + ASSERT_FALSE(bi_can_fma(fadd)); + ASSERT_TRUE(bi_can_add(fadd)); + + /* With equal abs but different sources */ + fadd->src[1] = bi_abs(y); + + ASSERT_TRUE(bi_can_fma(fadd)); + ASSERT_TRUE(bi_can_add(fadd)); + + /* With clamp */ + fadd->clamp = BI_CLAMP_CLAMP_M1_1; + + ASSERT_TRUE(bi_can_fma(fadd)); + ASSERT_FALSE(bi_can_add(fadd)); + + /* Impossible encoding (should never be seen) */ + fadd->src[1] = fadd->src[0]; + + ASSERT_FALSE(bi_can_fma(fadd)); + ASSERT_FALSE(bi_can_add(fadd)); +}