@@ -24,6 +24,56 @@ namespace {
24
24
25
25
using LocalSingleStoreElimTest = PassTest<::testing::Test>;
26
26
27
+ TEST_F (LocalSingleStoreElimTest, DoSomethingWithExtensions) {
28
+ const std::string capabilities_and_extensions =
29
+ R"( OpCapability Shader
30
+ OpExtension "SPV_EXT_fragment_shader_interlock"
31
+ OpExtension "SPV_NV_compute_shader_derivatives"
32
+ OpExtension "SPV_KHR_ray_query"
33
+ OpExtension "SPV_NV_shader_subgroup_partitioned"
34
+ OpExtension "SPV_KHR_ray_tracing"
35
+ OpExtension "SPV_EXT_descriptor_indexing"
36
+ )" ;
37
+
38
+ const std::string before = capabilities_and_extensions +
39
+ R"( %1 = OpExtInstImport "GLSL.std.450"
40
+ OpMemoryModel Logical GLSL450
41
+ OpEntryPoint Fragment %2 "main"
42
+ OpExecutionMode %2 OriginUpperLeft
43
+ OpSource GLSL 140
44
+ %void = OpTypeVoid
45
+ %4 = OpTypeFunction %void
46
+ %float = OpTypeFloat 32
47
+ %_ptr_Function_float = OpTypePointer Function %float
48
+ %float_0 = OpConstant %float 0
49
+ %2 = OpFunction %void None %4
50
+ %8 = OpLabel
51
+ %9 = OpVariable %_ptr_Function_float Function
52
+ OpStore %9 %float_0
53
+ %10 = OpLoad %float %9
54
+ OpReturn
55
+ OpFunctionEnd
56
+ )" ;
57
+ const std::string after = capabilities_and_extensions +
58
+ R"( %1 = OpExtInstImport "GLSL.std.450"
59
+ OpMemoryModel Logical GLSL450
60
+ OpEntryPoint Fragment %2 "main"
61
+ OpExecutionMode %2 OriginUpperLeft
62
+ OpSource GLSL 140
63
+ %void = OpTypeVoid
64
+ %4 = OpTypeFunction %void
65
+ %float = OpTypeFloat 32
66
+ %_ptr_Function_float = OpTypePointer Function %float
67
+ %float_0 = OpConstant %float 0
68
+ %2 = OpFunction %void None %4
69
+ %8 = OpLabel
70
+ %9 = OpVariable %_ptr_Function_float Function
71
+ OpStore %9 %float_0
72
+ OpReturn
73
+ OpFunctionEnd
74
+ )" ;
75
+ SinglePassRunAndCheck<LocalSingleStoreElimPass>(before, after, true , true );
76
+ }
27
77
TEST_F (LocalSingleStoreElimTest, PositiveAndNegative) {
28
78
// Single store to v is optimized. Multiple store to
29
79
// f is not optimized.
0 commit comments