diff --git a/src/compiler/nir/nir_opt_load_store_vectorize.c b/src/compiler/nir/nir_opt_load_store_vectorize.c index 04e5ffb79e6..be285e96767 100644 --- a/src/compiler/nir/nir_opt_load_store_vectorize.c +++ b/src/compiler/nir/nir_opt_load_store_vectorize.c @@ -681,6 +681,10 @@ new_bitsize_acceptable(struct vectorize_ctx *ctx, unsigned new_bit_size, unsigned high_offset = high->offset_signed - low->offset_signed; + /* This can cause issues when combining store data. */ + if (high_offset % (new_bit_size / 8) != 0) + return false; + /* check nir_extract_bits limitations */ unsigned common_bit_size = MIN2(get_bit_size(low), get_bit_size(high)); common_bit_size = MIN2(common_bit_size, new_bit_size); diff --git a/src/compiler/nir/tests/load_store_vectorizer_tests.cpp b/src/compiler/nir/tests/load_store_vectorizer_tests.cpp index 48dd1fb415f..633acc87824 100644 --- a/src/compiler/nir/tests/load_store_vectorizer_tests.cpp +++ b/src/compiler/nir/tests/load_store_vectorizer_tests.cpp @@ -755,6 +755,20 @@ TEST_F(nir_load_store_vectorize_test, ssbo_store_intersecting) ASSERT_EQ(nir_const_value_as_uint(cv[2], 32), 0x21); } +TEST_F(nir_load_store_vectorize_test, gitlab_issue_12946) +{ + create_store(nir_var_mem_ssbo, 0, 0, 0x1, 32, 2, 0x3); + create_store(nir_var_mem_ssbo, 0, 3, 0x2, 32, 1, 0x1); + + nir_validate_shader(b->shader, NULL); + ASSERT_EQ(count_intrinsics(nir_intrinsic_store_ssbo), 2); + + /* The original issue was the crash when running the pass. */ + EXPECT_TRUE(run_vectorizer(nir_var_mem_ssbo)); + + EXPECT_EQ(count_intrinsics(nir_intrinsic_store_ssbo), 2); +} + TEST_F(nir_load_store_vectorize_test, ssbo_store_identical) { create_store(nir_var_mem_ssbo, 0, 0, 0x1);