MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / TEST_F

Function TEST_F

test/opt/loop_optimizations/lcssa.cpp:77–145  ·  view source on GitHub ↗

Generated from the following GLSL + --eliminate-local-multi-store #version 330 core layout(location = 0) out vec4 c; void main() { int i = 0; for (; i < 10; i++) { } if (i != 0) { i = 1; } } */

Source from the content-addressed store, hash-verified

75}
76*/
77TEST_F(LCSSATest, SimpleLCSSA) {
78 const std::string text = R"(
79; CHECK: OpLoopMerge [[merge:%\w+]] %19 None
80; CHECK: [[merge]] = OpLabel
81; CHECK-NEXT: [[phi:%\w+]] = OpPhi {{%\w+}} %30 %20
82; CHECK-NEXT: %27 = OpINotEqual {{%\w+}} [[phi]] %9
83 OpCapability Shader
84 %1 = OpExtInstImport "GLSL.std.450"
85 OpMemoryModel Logical GLSL450
86 OpEntryPoint Fragment %2 "main" %3
87 OpExecutionMode %2 OriginUpperLeft
88 OpSource GLSL 330
89 OpName %2 "main"
90 OpName %3 "c"
91 OpDecorate %3 Location 0
92 %5 = OpTypeVoid
93 %6 = OpTypeFunction %5
94 %7 = OpTypeInt 32 1
95 %8 = OpTypePointer Function %7
96 %9 = OpConstant %7 0
97 %10 = OpConstant %7 10
98 %11 = OpTypeBool
99 %12 = OpConstant %7 1
100 %13 = OpTypeFloat 32
101 %14 = OpTypeVector %13 4
102 %15 = OpTypePointer Output %14
103 %3 = OpVariable %15 Output
104 %2 = OpFunction %5 None %6
105 %16 = OpLabel
106 OpBranch %17
107 %17 = OpLabel
108 %30 = OpPhi %7 %9 %16 %25 %19
109 OpLoopMerge %18 %19 None
110 OpBranch %20
111 %20 = OpLabel
112 %22 = OpSLessThan %11 %30 %10
113 OpBranchConditional %22 %23 %18
114 %23 = OpLabel
115 OpBranch %19
116 %19 = OpLabel
117 %25 = OpIAdd %7 %30 %12
118 OpBranch %17
119 %18 = OpLabel
120 %27 = OpINotEqual %11 %30 %9
121 OpSelectionMerge %28 None
122 OpBranchConditional %27 %29 %28
123 %29 = OpLabel
124 OpBranch %28
125 %28 = OpLabel
126 %31 = OpPhi %7 %30 %18 %12 %29
127 OpReturn
128 OpFunctionEnd
129 )";
130 std::unique_ptr<IRContext> context =
131 BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
132 SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
133 Module* module = context->module();
134 EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"

Callers

nothing calls this directly

Calls 7

GetFunctionFunction · 0.85
getMethod · 0.80
IsLCSSAMethod · 0.80
MakeLoopClosedSSAMethod · 0.80
MatchFunction · 0.70
BuildModuleFunction · 0.50
moduleMethod · 0.45

Tested by

no test coverage detected