From 54c7099087fc400a3afba1062b4fa7f66569651c Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Thu, 10 Aug 2023 10:48:49 +0100 Subject: [PATCH] panfrost: upcast uint8/uint16 before shifting them beyond their range ../src/panfrost/compiler/compiler.h:89:14: runtime error: left shift of 51966 by 16 places cannot be represented in type 'int' #0 0x55c72fd7dda4 in bi_apply_swizzle ../src/panfrost/compiler/compiler.h:89 #1 0x55c72fd808d6 in bi_source_value ../src/panfrost/compiler/bi_opt_constant_fold.c:35 #2 0x55c72fd80a83 in bi_fold_constant ../src/panfrost/compiler/bi_opt_constant_fold.c:52 #3 0x55c72fb2080c in constant_fold_pred ../src/panfrost/compiler/test/test-constant-fold.cpp:48 #4 0x55c72fb21a65 in ConstantFold_Swizzles_Test::TestBody() ../src/panfrost/compiler/test/test-constant-fold.cpp:103 #5 0x55c73070cc97 in void testing::internal::HandleSehExceptionsInMethodIfSupported(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2621 #6 0x55c7306f0df7 in void testing::internal::HandleExceptionsInMethodIfSupported(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2657 #7 0x55c730694add in testing::Test::Run() ../src/gtest/src/gtest.cc:2696 #8 0x55c73069798d in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2845 #9 0x55c73069b684 in testing::TestSuite::Run() ../src/gtest/src/gtest.cc:3004 #10 0x55c7306ccfcb in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:5890 #11 0x55c73071053c in bool testing::internal::HandleSehExceptionsInMethodIfSupported(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2621 #12 0x55c7306f4ed3 in bool testing::internal::HandleExceptionsInMethodIfSupported(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2657 #13 0x55c7306c23fa in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:5455 #14 0x55c730748faf in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2314 #15 0x55c730748ffa in main ../src/gtest/src/gtest_main.cc:63 #16 0x7f8554bcc1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 #17 0x7f8554bcc284 in __libc_start_main_impl ../csu/libc-start.c:360 #18 0x55c72fb18be0 in _start (/builds/mesa/mesa/_build/src/panfrost/compiler/bifrost_tests+0xbd0be0) Cc: mesa-stable Signed-off-by: Eric Engestrom Part-of: --- src/panfrost/compiler/compiler.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/panfrost/compiler/compiler.h b/src/panfrost/compiler/compiler.h index f1d98a8..835450e 100644 --- a/src/panfrost/compiler/compiler.h +++ b/src/panfrost/compiler/compiler.h @@ -79,8 +79,10 @@ bi_apply_swizzle(uint32_t value, enum bi_swizzle swz) const uint16_t *h = (const uint16_t *)&value; const uint8_t *b = (const uint8_t *)&value; -#define H(h0, h1) (h[h0] | (h[h1] << 16)) -#define B(b0, b1, b2, b3) (b[b0] | (b[b1] << 8) | (b[b2] << 16) | (b[b3] << 24)) +#define H(h0, h1) (h[h0] | ((uint32_t)h[h1] << 16)) +#define B(b0, b1, b2, b3) \ + (b[b0] | ((uint32_t)b[b1] << 8) | ((uint32_t)b[b2] << 16) | \ + ((uint32_t)b[b3] << 24)) switch (swz) { case BI_SWIZZLE_H00: -- 2.7.4