Mesa (main): pan/bi: Constant fold MKVEC.v2i8

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 21 22:55:23 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Fri Jun 17 11:55:23 2022 -0400

pan/bi: Constant fold MKVEC.v2i8

Constant MKVEC.v2i8 will be generated during texturing on Valhall, just like
constant MKVEC.v4i8 is currently generated.

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

---

 src/panfrost/bifrost/bi_opt_constant_fold.c      |  3 +++
 src/panfrost/bifrost/test/test-constant-fold.cpp | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/panfrost/bifrost/bi_opt_constant_fold.c b/src/panfrost/bifrost/bi_opt_constant_fold.c
index 2679b9da9ad..009938588ce 100644
--- a/src/panfrost/bifrost/bi_opt_constant_fold.c
+++ b/src/panfrost/bifrost/bi_opt_constant_fold.c
@@ -58,6 +58,9 @@ bi_fold_constant(bi_instr *I, bool *unsupported)
         case BI_OPCODE_MKVEC_V4I8:
                 return (d << 24) | ((c & 0xFF) << 16) | ((b & 0xFF) << 8) | (a & 0xFF);
 
+        case BI_OPCODE_MKVEC_V2I8:
+                return (c << 16) | ((b & 0xFF) << 8) | (a & 0xFF);
+
         case BI_OPCODE_LSHIFT_OR_I32:
                 if (I->not_result || I->src[0].neg || I->src[1].neg)
                         break;
diff --git a/src/panfrost/bifrost/test/test-constant-fold.cpp b/src/panfrost/bifrost/test/test-constant-fold.cpp
index d28fc953ae8..90a63862ee1 100644
--- a/src/panfrost/bifrost/test/test-constant-fold.cpp
+++ b/src/panfrost/bifrost/test/test-constant-fold.cpp
@@ -152,6 +152,23 @@ TEST_F(ConstantFold, VectorConstructions4i8)
    EXPECT_FOLD(bi_mkvec_v4i8_to(b, reg, c, c, c, c), 0xFEFEFEFE);
 }
 
+TEST_F(ConstantFold, VectorConstructions2i8)
+{
+   bi_index reg = bi_register(0);
+   bi_index u32 = bi_imm_u32(0xCAFEBABE);
+   bi_index rem = bi_imm_u32(0xABCD1234);
+
+   bi_index a = bi_byte(u32, 0); /* 0xBE */
+   bi_index B = bi_byte(u32, 1); /* 0xBA */
+   bi_index c = bi_byte(u32, 2); /* 0xFE */
+   bi_index d = bi_byte(u32, 3); /* 0xCA */
+
+   EXPECT_FOLD(bi_mkvec_v2i8_to(b, reg, a, B, rem), 0x1234BABE);
+   EXPECT_FOLD(bi_mkvec_v2i8_to(b, reg, a, d, rem), 0x1234CABE);
+   EXPECT_FOLD(bi_mkvec_v2i8_to(b, reg, c, d, rem), 0x1234CAFE);
+   EXPECT_FOLD(bi_mkvec_v2i8_to(b, reg, d, d, rem), 0x1234CACA);
+}
+
 TEST_F(ConstantFold, LimitedShiftsForTexturing)
 {
    bi_index reg = bi_register(0);



More information about the mesa-commit mailing list