Test zero scalar shift folding on RDNA2 compute shader

This commit is contained in:
nmzik
2026-09-24 01:59:52 +04:00
parent 3b89e36d1e
commit 51c34d1a24
+32
View File
@@ -16610,6 +16610,32 @@ TestCase Shifts() {
O::BUFFER_STORE_DWORD, O::S_ENDPGM}}; O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
} }
TestCase ScalarZeroShiftWithRuntimeCount() {
using O = ShaderOpcode;
std::vector<u32> code = {
EncodeSop2(0x20, 8, InlineU32(0), 4),
EncodeSop2(0x20, 9, 6, 4),
};
AppendStoreSgpr(&code, 8, 0);
AppendStoreSgpr(&code, 9, 1);
AppendEnd(&code);
TestCase test;
test.name = "ScalarZeroShiftWithRuntimeCount";
test.code = std::move(code);
test.expected = {0, 0x40000000u};
test.opcodes = {O::S_LSHR_B32, O::V_MOV_B32, O::BUFFER_STORE_DWORD,
O::S_ENDPGM};
test.user_data = MakeStructuredStorageBufferData(0, 2 * sizeof(u32));
test.user_data[4] = 33;
test.user_data[6] = 0x80000000u;
test.has_user_data = true;
test.ir_counts = {{" = ShiftRightLogical32 ", 1}};
test.required_spirv = {"OpShiftRightLogical"};
return test;
}
TestCase ExactPushConstantExtent() { TestCase ExactPushConstantExtent() {
using O = ShaderOpcode; using O = ShaderOpcode;
@@ -27970,6 +27996,7 @@ std::vector<TestCase> MakeCases() {
AddCase(IntegerAddSubMul); AddCase(IntegerAddSubMul);
AddCase(BitwiseOps); AddCase(BitwiseOps);
AddCase(Shifts); AddCase(Shifts);
AddCase(ScalarZeroShiftWithRuntimeCount);
AddCase(ExactPushConstantExtent); AddCase(ExactPushConstantExtent);
AddCase(ScalarShiftCountsMaskLowBits); AddCase(ScalarShiftCountsMaskLowBits);
AddCase(Rdna2ScalarOpcodes); AddCase(Rdna2ScalarOpcodes);
@@ -33045,6 +33072,11 @@ int main(int argc, char **argv) {
RunCase(&vulkan, VectorAlignByteUsesFiveBitByteOffset()); RunCase(&vulkan, VectorAlignByteUsesFiveBitByteOffset());
return 0; return 0;
} }
if (argc == 2 && std::strcmp(argv[1], "--zero-shift-only") == 0) {
VulkanHarness vulkan;
RunCase(&vulkan, ScalarZeroShiftWithRuntimeCount());
return 0;
}
if (argc == 2 && std::strcmp(argv[1], "--sdwa-mov-only") == 0) { if (argc == 2 && std::strcmp(argv[1], "--sdwa-mov-only") == 0) {
VulkanHarness vulkan; VulkanHarness vulkan;
RunCase(&vulkan, Vop1SdwaMovByteDestinations()); RunCase(&vulkan, Vop1SdwaMovByteDestinations());