diff --git a/src/tint/writer/spirv/generator_impl.cc b/src/tint/writer/spirv/generator_impl.cc index a435fb8a16..8586562741 100644 --- a/src/tint/writer/spirv/generator_impl.cc +++ b/src/tint/writer/spirv/generator_impl.cc @@ -26,6 +26,7 @@ #include "src/tint/transform/for_loop_to_loop.h" #include "src/tint/transform/manager.h" #include "src/tint/transform/promote_side_effects_to_decl.h" +#include "src/tint/transform/remove_phonies.h" #include "src/tint/transform/remove_unreachable_statements.h" #include "src/tint/transform/simplify_pointers.h" #include "src/tint/transform/unshadow.h" @@ -75,6 +76,7 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { manager.Add(); manager.Add(); manager.Add(); // Required for arrayLength() + manager.Add(); manager.Add(); manager.Add(); // Must come after manager.Add(); // ZeroInitWorkgroupMemory diff --git a/test/tint/bug/tint/1046.wgsl.expected.spvasm b/test/tint/bug/tint/1046.wgsl.expected.spvasm index 591ded6f2e..5d68d323f0 100644 --- a/test/tint/bug/tint/1046.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1046.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 108 +; Bound: 107 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -129,7 +129,7 @@ %92 = OpConstantNull %float %93 = OpConstantComposite %v4float %float_1 %92 %92 %float_1 %void = OpTypeVoid - %96 = OpTypeFunction %void + %95 = OpTypeFunction %void %getColor = OpFunction %v4float None %30 %fragment = OpFunctionParameter %FragmentInput %34 = OpLabel @@ -196,19 +196,19 @@ %output = OpVariable %_ptr_Function_FragmentOutput Function %89 %91 = OpAccessChain %_ptr_Function_v4float %output %uint_0 OpStore %91 %93 - %95 = OpLoad %FragmentOutput %output - OpReturnValue %95 + %94 = OpLoad %FragmentOutput %output + OpReturnValue %94 OpFunctionEnd - %main = OpFunction %void None %96 - %99 = OpLabel - %101 = OpLoad %v4float %position_1 - %102 = OpLoad %v4float %view_position_1 - %103 = OpLoad %v4float %normal_1 - %104 = OpLoad %v2float %uv_1 - %105 = OpLoad %v4float %color_1 - %106 = OpCompositeConstruct %FragmentInput %101 %102 %103 %104 %105 - %100 = OpFunctionCall %FragmentOutput %main_inner %106 - %107 = OpCompositeExtract %v4float %100 0 - OpStore %color_2 %107 + %main = OpFunction %void None %95 + %98 = OpLabel + %100 = OpLoad %v4float %position_1 + %101 = OpLoad %v4float %view_position_1 + %102 = OpLoad %v4float %normal_1 + %103 = OpLoad %v2float %uv_1 + %104 = OpLoad %v4float %color_1 + %105 = OpCompositeConstruct %FragmentInput %100 %101 %102 %103 %104 + %99 = OpFunctionCall %FragmentOutput %main_inner %105 + %106 = OpCompositeExtract %v4float %99 0 + OpStore %color_2 %106 OpReturn OpFunctionEnd diff --git a/test/tint/statements/assign/phony/addr_of_non_constructable.wgsl.expected.spvasm b/test/tint/statements/assign/phony/addr_of_non_constructable.wgsl.expected.spvasm index 36a09629dc..91198147ba 100644 --- a/test/tint/statements/assign/phony/addr_of_non_constructable.wgsl.expected.spvasm +++ b/test/tint/statements/assign/phony/addr_of_non_constructable.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 11 +; Bound: 10 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 diff --git a/test/tint/statements/assign/phony/addr_of_runtime_array.wgsl.expected.spvasm b/test/tint/statements/assign/phony/addr_of_runtime_array.wgsl.expected.spvasm index 8a335943f5..91198147ba 100644 --- a/test/tint/statements/assign/phony/addr_of_runtime_array.wgsl.expected.spvasm +++ b/test/tint/statements/assign/phony/addr_of_runtime_array.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 15 +; Bound: 10 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -23,11 +23,7 @@ %s = OpVariable %_ptr_StorageBuffer_S StorageBuffer %void = OpTypeVoid %6 = OpTypeFunction %void - %uint = OpTypeInt 32 0 - %uint_0 = OpConstant %uint 0 -%_ptr_StorageBuffer__runtimearr_int = OpTypePointer StorageBuffer %_runtimearr_int %main = OpFunction %void None %6 %9 = OpLabel - %14 = OpAccessChain %_ptr_StorageBuffer__runtimearr_int %s %uint_0 OpReturn OpFunctionEnd diff --git a/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm b/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm index 7b0f464f4e..cde6ee0535 100644 --- a/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm +++ b/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 31 +; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -42,7 +42,5 @@ %18 = OpFunctionCall %int %f %int_4 %int_5 %int_6 %22 = OpFunctionCall %int %f %int_8 %int_9 %int_10 %26 = OpFunctionCall %int %f %int_7 %22 %int_11 - %29 = OpIMul %int %18 %26 - %30 = OpIAdd %int %14 %29 OpReturn OpFunctionEnd diff --git a/test/tint/statements/assign/phony/storage_buffer.wgsl.expected.spvasm b/test/tint/statements/assign/phony/storage_buffer.wgsl.expected.spvasm index ff08f0d3e6..41a786bd17 100644 --- a/test/tint/statements/assign/phony/storage_buffer.wgsl.expected.spvasm +++ b/test/tint/statements/assign/phony/storage_buffer.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 13 +; Bound: 9 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -21,11 +21,7 @@ %s = OpVariable %_ptr_StorageBuffer_S StorageBuffer %void = OpTypeVoid %5 = OpTypeFunction %void - %uint = OpTypeInt 32 0 - %uint_0 = OpConstant %uint 0 -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %main = OpFunction %void None %5 %8 = OpLabel - %12 = OpAccessChain %_ptr_StorageBuffer_int %s %uint_0 OpReturn OpFunctionEnd diff --git a/test/tint/statements/assign/phony/uniform_buffer.wgsl.expected.spvasm b/test/tint/statements/assign/phony/uniform_buffer.wgsl.expected.spvasm index aa242e7805..06508a884e 100644 --- a/test/tint/statements/assign/phony/uniform_buffer.wgsl.expected.spvasm +++ b/test/tint/statements/assign/phony/uniform_buffer.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 13 +; Bound: 9 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -22,11 +22,7 @@ %u = OpVariable %_ptr_Uniform_S Uniform %void = OpTypeVoid %5 = OpTypeFunction %void - %uint = OpTypeInt 32 0 - %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_int = OpTypePointer Uniform %int %main = OpFunction %void None %5 %8 = OpLabel - %12 = OpAccessChain %_ptr_Uniform_int %u %uint_0 OpReturn OpFunctionEnd