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);