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@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17101>
This commit is contained in:
Alyssa Rosenzweig 2022-06-17 11:55:23 -04:00 committed by Marge Bot
parent 2833d0472a
commit 10301885ab
2 changed files with 20 additions and 0 deletions

View file

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

View file

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