Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Deduplicate constant data tables #2854

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions llpc/test/shaderdb/general/TestDeduplicateConstTables.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// BEGIN_SHADERTEST
// RUN: amdllpc -v %gfxip %s | FileCheck -check-prefix=SHADERTEST %s
// SHADERTEST-LABEL: {{^// LLPC}} SPIRV-to-LLVM translation results
// SHADERTEST: [[VAR1:@.*]] = addrspace(5) constant [28 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
// SHADERTEST: [[VAR2:@.*]] = addrspace(5) constant [28 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
// SHADERTEST: [[VAR3:@.*]] = addrspace(5) constant [28 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
// SHADERTEST: [[VAR4:@.*]] = addrspace(5) constant [28 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
// SHADERTEST: [[VAR5:@.*]] = addrspace(5) constant [28 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
// SHADERTEST: [[VAR6:@.*]] = addrspace(5) constant [28 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(5) [[VAR1]], i32
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(5) [[VAR2]], i32
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(5) [[VAR3]], i32
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(5) [[VAR4]], i32
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(5) [[VAR5]], i32
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(5) [[VAR6]], i32
//
// SHADERTEST-LABEL: {{^// LLPC}} SPIR-V lowering results
// SHADERTEST: [[VAR:@.*]] = internal unnamed_addr addrspace(4) constant [28 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(4) [[VAR]], i64
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(4) [[VAR]], i64
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(4) [[VAR]], i64
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(4) [[VAR]], i64
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(4) [[VAR]], i64
// SHADERTEST: getelementptr [28 x <4 x i32>], ptr addrspace(4) [[VAR]], i64
// SHADERTEST: AMDLLPC SUCCESS
// END_SHADERTEST


#version 460

const uvec4 _211[28] = uvec4[](uvec4(1059055552u, 1057692236u, 1062465857u, 0u), uvec4(3188284415u, 3211912104u, 1064587336u, 0u), uvec4(1053197116u, 3202258829u, 1058349232u, 0u), uvec4(1039685418u, 3192222363u, 1047084841u, 0u), uvec4(3192964587u, 1038352636u, 1047388173u, 0u), uvec4(1062520215u, 3197474974u, 1063356727u, 0u), uvec4(1037850661u, 3205763422u, 1058446204u, 0u), uvec4(1049678263u, 1061836040u, 1062659634u, 0u), uvec4(3199959344u, 1053446761u, 1057614893u, 0u), uvec4(1061258065u, 1046506363u, 1061780340u, 0u), uvec4(3204886141u, 1019442700u, 1057411553u, 0u), uvec4(3210859837u, 3195704642u, 1063935038u, 0u), uvec4(3204075131u, 3197512555u, 1058140859u, 0u), uvec4(1054956040u, 3182380177u, 1055232528u, 0u), uvec4(1046011770u, 1057194959u, 1057898596u, 0u), uvec4(1029739884u, 1064631963u, 1064658304u, 0u), uvec4(3205958373u, 3207889095u, 1064000637u, 0u), uvec4(3209492326u, 1048328368u, 1062629938u, 0u), uvec4(3192317658u, 3191631805u, 1049165551u, 0u), uvec4(3202323254u, 1061452681u, 1063390953u, 0u), uvec4(1046338590u, 1038982117u, 1048292130u, 0u), uvec4(1042332191u, 3210420945u, 1063176708u, 0u), uvec4(3208780301u, 1058367687u, 1064628776u, 0u), uvec4(1065233091u, 3169707339u, 1065240305u, 0u), uvec4(3194203417u, 3205774830u, 1058982739u, 0u), uvec4(1057812193u, 3207297698u, 1063122517u, 0u), uvec4(1055767050u, 1049621221u, 1057682673u, 0u), uvec4(3180576291u, 1058735275u, 1058807082u, 0u));

layout(binding = 0) uniform Uniforms
{
int in1;
};

layout(location = 0) out vec4 _out;

void main()
{
for (uint i = 0; i < 28; i++)
{
if (in1 != 1)
{
_out = _out + vec4(_211[i+in1].x, _211[i].y, _211[i].wx);
}
_out = _out + vec4(_211[in1].x, _211[i].y, _211[i].wx);
}
}

120 changes: 120 additions & 0 deletions llpc/test/shaderdb/general/TestDeduplicateConstTables.spvasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
; BEGIN_SHADERTEST
; RUN: amdllpc -v %gfxip %s | FileCheck -check-prefix=SHADERTEST %s
; SHADERTEST-LABEL: {{^// LLPC}} SPIRV-to-LLVM translation results
; SHADERTEST: store [2 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857
; SHADERTEST: store [2 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857
; SHADERTEST: store [2 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857

; SHADERTEST-LABEL: {{^// LLPC}} SPIR-V lowering results
; SHADERTEST: [[VAR:@.*]] = internal unnamed_addr addrspace(4) constant [2 x <4 x i32>] [<4 x i32> <i32 1059055552, i32 1057692236, i32 1062465857, i32 0
; SHADERTEST: getelementptr [2 x <4 x i32>], ptr addrspace(4) [[VAR]]
; SHADERTEST: getelementptr [2 x <4 x i32>], ptr addrspace(4) [[VAR]]
; SHADERTEST: getelementptr [2 x <4 x i32>], ptr addrspace(4) [[VAR]]
; SHADERTEST: AMDLLPC SUCCESS
; END_SHADERTEST


; SPIR-V
; Version: 1.6
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 70
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %_out %_
OpExecutionMode %main OriginUpperLeft
OpSource GLSL 460
OpName %main "main"
OpName %i "i"
OpName %_out "_out"
OpName %Uniforms "Uniforms"
OpMemberName %Uniforms 0 "in1"
OpName %_ ""
OpDecorate %_out Location 0
OpMemberDecorate %Uniforms 0 Offset 0
OpDecorate %Uniforms Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%uint_0 = OpConstant %uint 0
%uint_2 = OpConstant %uint 2
%bool = OpTypeBool
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_out = OpVariable %_ptr_Output_v4float Output
%v4uint = OpTypeVector %uint 4
%_arr_v4uint_uint_2 = OpTypeArray %v4uint %uint_2
%uint_1059055552 = OpConstant %uint 1059055552
%uint_1057692236 = OpConstant %uint 1057692236
%uint_1062465857 = OpConstant %uint 1062465857
%29 = OpConstantComposite %v4uint %uint_1059055552 %uint_1057692236 %uint_1062465857 %uint_0
%uint_3188284415 = OpConstant %uint 3188284415
%uint_3211912104 = OpConstant %uint 3211912104
%uint_1064587336 = OpConstant %uint 1064587336
%33 = OpConstantComposite %v4uint %uint_3188284415 %uint_3211912104 %uint_1064587336 %uint_0
%34 = OpConstantComposite %_arr_v4uint_uint_2 %29 %33
%int = OpTypeInt 32 1
%Uniforms = OpTypeStruct %int
%_ptr_Uniform_Uniforms = OpTypePointer Uniform %Uniforms
%_ = OpVariable %_ptr_Uniform_Uniforms Uniform
%int_0 = OpConstant %int 0
%_ptr_Uniform_int = OpTypePointer Uniform %int
%_ptr_Function__arr_v4uint_uint_2 = OpTypePointer Function %_arr_v4uint_uint_2
%uint_1 = OpConstant %uint 1
%v2uint = OpTypeVector %uint 2
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
%v2float = OpTypeVector %float 2
%int_1 = OpConstant %int 1
%main = OpFunction %void None %3
%5 = OpLabel
%i = OpVariable %_ptr_Function_uint Function
%indexable = OpVariable %_ptr_Function__arr_v4uint_uint_2 Function
%indexable_0 = OpVariable %_ptr_Function__arr_v4uint_uint_2 Function
%indexable_1 = OpVariable %_ptr_Function__arr_v4uint_uint_2 Function
OpStore %indexable %34
OpStore %indexable_0 %34
OpStore %indexable_1 %34
OpStore %i %uint_0
OpBranch %10
%10 = OpLabel
OpLoopMerge %12 %13 None
OpBranch %14
%14 = OpLabel
%15 = OpLoad %uint %i
%18 = OpULessThan %bool %15 %uint_2
OpBranchConditional %18 %11 %12
%11 = OpLabel
%23 = OpLoad %v4float %_out
%41 = OpAccessChain %_ptr_Uniform_int %_ %int_0
%42 = OpLoad %int %41
%45 = OpAccessChain %_ptr_Function_uint %indexable %42 %uint_0
%46 = OpLoad %uint %45
%47 = OpConvertUToF %float %46
%48 = OpLoad %uint %i
%51 = OpAccessChain %_ptr_Function_uint %indexable_0 %48 %uint_1
%52 = OpLoad %uint %51
%53 = OpConvertUToF %float %52
%54 = OpLoad %uint %i
%58 = OpAccessChain %_ptr_Function_v4uint %indexable_1 %54
%59 = OpLoad %v4uint %58
%60 = OpVectorShuffle %v2uint %59 %59 3 0
%62 = OpConvertUToF %v2float %60
%63 = OpCompositeExtract %float %62 0
%64 = OpCompositeExtract %float %62 1
%65 = OpCompositeConstruct %v4float %47 %53 %63 %64
%66 = OpFAdd %v4float %23 %65
OpStore %_out %66
OpBranch %13
%13 = OpLabel
%67 = OpLoad %uint %i
%69 = OpIAdd %uint %67 %int_1
OpStore %i %69
OpBranch %10
%12 = OpLabel
OpReturn
OpFunctionEnd
Loading