1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by generate_tests.py
3 //
4 // Copyright (c) 2022 Google LLC.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17
18 #include "../diff_test_utils.h"
19
20 #include "gtest/gtest.h"
21
22 namespace spvtools {
23 namespace diff {
24 namespace {
25
26 // Test where src and dst have a few large functions with large differences.
27 constexpr char kSrc[] = R"( OpCapability Shader
28 %1 = OpExtInstImport "GLSL.std.450"
29 OpMemoryModel Logical GLSL450
30 OpEntryPoint GLCompute %4 "main" %15
31 OpExecutionMode %4 LocalSize 1 1 1
32 OpSource ESSL 310
33 OpName %4 "main"
34 OpName %6 "f1("
35 OpName %8 "f2("
36 OpName %12 "x"
37 OpName %15 "gl_LocalInvocationID"
38 OpName %20 "y"
39 OpName %27 "image"
40 OpName %44 "sum"
41 OpName %46 "i"
42 OpName %56 "j"
43 OpName %80 "BufferOut"
44 OpMemberName %80 0 "o_uv4"
45 OpMemberName %80 1 "o_v3"
46 OpMemberName %80 2 "o_i"
47 OpName %82 ""
48 OpName %88 "BufferIn"
49 OpMemberName %88 0 "i_u"
50 OpMemberName %88 1 "i_v4"
51 OpMemberName %88 2 "i_f"
52 OpName %90 ""
53 OpName %101 "i"
54 OpName %128 "image2"
55 OpDecorate %15 BuiltIn LocalInvocationId
56 OpDecorate %27 DescriptorSet 0
57 OpDecorate %27 Binding 2
58 OpMemberDecorate %80 0 Offset 0
59 OpMemberDecorate %80 1 Offset 16
60 OpMemberDecorate %80 2 Offset 28
61 OpDecorate %80 BufferBlock
62 OpDecorate %82 DescriptorSet 0
63 OpDecorate %82 Binding 1
64 OpMemberDecorate %88 0 Offset 0
65 OpMemberDecorate %88 1 RowMajor
66 OpMemberDecorate %88 1 Offset 16
67 OpMemberDecorate %88 1 MatrixStride 16
68 OpMemberDecorate %88 2 Offset 80
69 OpDecorate %88 Block
70 OpDecorate %90 DescriptorSet 0
71 OpDecorate %90 Binding 0
72 OpDecorate %128 DescriptorSet 0
73 OpDecorate %128 Binding 3
74 %2 = OpTypeVoid
75 %3 = OpTypeFunction %2
76 %10 = OpTypeInt 32 0
77 %11 = OpTypePointer Function %10
78 %13 = OpTypeVector %10 3
79 %14 = OpTypePointer Input %13
80 %15 = OpVariable %14 Input
81 %16 = OpConstant %10 0
82 %17 = OpTypePointer Input %10
83 %21 = OpConstant %10 1
84 %24 = OpTypeInt 32 1
85 %25 = OpTypeImage %24 2D 0 0 0 2 R32i
86 %26 = OpTypePointer UniformConstant %25
87 %27 = OpVariable %26 UniformConstant
88 %29 = OpTypeVector %10 2
89 %32 = OpTypeVector %24 2
90 %38 = OpTypeVector %24 4
91 %40 = OpConstant %10 2
92 %41 = OpConstant %10 3400
93 %42 = OpConstant %10 264
94 %43 = OpTypePointer Function %24
95 %45 = OpConstant %24 0
96 %53 = OpConstant %24 2
97 %54 = OpTypeBool
98 %73 = OpConstant %24 1
99 %77 = OpTypeVector %10 4
100 %78 = OpTypeFloat 32
101 %79 = OpTypeVector %78 3
102 %80 = OpTypeStruct %77 %79 %24
103 %81 = OpTypePointer Uniform %80
104 %82 = OpVariable %81 Uniform
105 %84 = OpTypePointer Uniform %24
106 %86 = OpTypeVector %78 4
107 %87 = OpTypeMatrix %86 4
108 %88 = OpTypeStruct %10 %87 %78
109 %89 = OpTypePointer Uniform %88
110 %90 = OpVariable %89 Uniform
111 %91 = OpTypePointer Uniform %87
112 %94 = OpTypePointer Uniform %77
113 %108 = OpConstant %24 3
114 %110 = OpTypePointer Uniform %79
115 %113 = OpTypePointer Uniform %78
116 %128 = OpVariable %26 UniformConstant
117 %130 = OpConstantComposite %32 %45 %45
118 %4 = OpFunction %2 None %3
119 %5 = OpLabel
120 %136 = OpFunctionCall %2 %6
121 %137 = OpFunctionCall %2 %8
122 OpReturn
123 OpFunctionEnd
124 %6 = OpFunction %2 None %3
125 %7 = OpLabel
126 %12 = OpVariable %11 Function
127 %20 = OpVariable %11 Function
128 %44 = OpVariable %43 Function
129 %46 = OpVariable %43 Function
130 %56 = OpVariable %43 Function
131 %18 = OpAccessChain %17 %15 %16
132 %19 = OpLoad %10 %18
133 OpStore %12 %19
134 %22 = OpAccessChain %17 %15 %21
135 %23 = OpLoad %10 %22
136 OpStore %20 %23
137 %28 = OpLoad %25 %27
138 %30 = OpLoad %13 %15
139 %31 = OpVectorShuffle %29 %30 %30 0 1
140 %33 = OpBitcast %32 %31
141 %34 = OpLoad %10 %12
142 %35 = OpLoad %10 %20
143 %36 = OpIAdd %10 %34 %35
144 %37 = OpBitcast %24 %36
145 %39 = OpCompositeConstruct %38 %37 %37 %37 %37
146 OpImageWrite %28 %33 %39
147 OpMemoryBarrier %40 %41
148 OpControlBarrier %40 %40 %42
149 OpStore %44 %45
150 OpStore %46 %45
151 OpBranch %47
152 %47 = OpLabel
153 OpLoopMerge %49 %50 None
154 OpBranch %51
155 %51 = OpLabel
156 %52 = OpLoad %24 %46
157 %55 = OpSLessThan %54 %52 %53
158 OpBranchConditional %55 %48 %49
159 %48 = OpLabel
160 OpStore %56 %45
161 OpBranch %57
162 %57 = OpLabel
163 OpLoopMerge %59 %60 None
164 OpBranch %61
165 %61 = OpLabel
166 %62 = OpLoad %24 %56
167 %63 = OpSLessThan %54 %62 %53
168 OpBranchConditional %63 %58 %59
169 %58 = OpLabel
170 %64 = OpLoad %25 %27
171 %65 = OpLoad %24 %46
172 %66 = OpLoad %24 %56
173 %67 = OpCompositeConstruct %32 %65 %66
174 %68 = OpImageRead %38 %64 %67
175 %69 = OpCompositeExtract %24 %68 0
176 %70 = OpLoad %24 %44
177 %71 = OpIMul %24 %70 %69
178 OpStore %44 %71
179 OpBranch %60
180 %60 = OpLabel
181 %72 = OpLoad %24 %56
182 %74 = OpIAdd %24 %72 %73
183 OpStore %56 %74
184 OpBranch %57
185 %59 = OpLabel
186 OpBranch %50
187 %50 = OpLabel
188 %75 = OpLoad %24 %46
189 %76 = OpIAdd %24 %75 %73
190 OpStore %46 %76
191 OpBranch %47
192 %49 = OpLabel
193 OpMemoryBarrier %40 %41
194 OpControlBarrier %40 %40 %42
195 %83 = OpLoad %24 %44
196 %85 = OpAccessChain %84 %82 %53
197 OpStore %85 %83
198 OpReturn
199 OpFunctionEnd
200 %8 = OpFunction %2 None %3
201 %9 = OpLabel
202 %101 = OpVariable %43 Function
203 %92 = OpAccessChain %91 %90 %73
204 %93 = OpLoad %87 %92
205 %95 = OpAccessChain %94 %82 %45
206 %96 = OpLoad %77 %95
207 %97 = OpConvertUToF %86 %96
208 %98 = OpMatrixTimesVector %86 %93 %97
209 %99 = OpConvertFToU %77 %98
210 %100 = OpAccessChain %94 %82 %45
211 OpStore %100 %99
212 OpStore %101 %45
213 OpBranch %102
214 %102 = OpLabel
215 OpLoopMerge %104 %105 None
216 OpBranch %106
217 %106 = OpLabel
218 %107 = OpLoad %24 %101
219 %109 = OpSLessThan %54 %107 %108
220 OpBranchConditional %109 %103 %104
221 %103 = OpLabel
222 %111 = OpAccessChain %110 %82 %73
223 %112 = OpLoad %79 %111
224 %114 = OpAccessChain %113 %90 %53
225 %115 = OpLoad %78 %114
226 %116 = OpVectorTimesScalar %79 %112 %115
227 %117 = OpConvertFToU %13 %116
228 %118 = OpCompositeExtract %10 %117 0
229 %119 = OpCompositeExtract %10 %117 1
230 %120 = OpCompositeExtract %10 %117 2
231 %121 = OpCompositeConstruct %77 %118 %119 %120 %16
232 %122 = OpAccessChain %94 %82 %45
233 %123 = OpLoad %77 %122
234 %124 = OpIAdd %77 %123 %121
235 %125 = OpAccessChain %94 %82 %45
236 OpStore %125 %124
237 OpBranch %105
238 %105 = OpLabel
239 %126 = OpLoad %24 %101
240 %127 = OpIAdd %24 %126 %73
241 OpStore %101 %127
242 OpBranch %102
243 %104 = OpLabel
244 OpMemoryBarrier %40 %41
245 OpControlBarrier %40 %40 %42
246 %129 = OpLoad %25 %128
247 %131 = OpImageRead %38 %129 %130
248 %132 = OpCompositeExtract %24 %131 0
249 %133 = OpConvertSToF %78 %132
250 %134 = OpCompositeConstruct %79 %133 %133 %133
251 %135 = OpAccessChain %110 %82 %73
252 OpStore %135 %134
253 OpReturn
254 OpFunctionEnd
255 )";
256 constexpr char kDst[] = R"( OpCapability Shader
257 %1 = OpExtInstImport "GLSL.std.450"
258 OpMemoryModel Logical GLSL450
259 OpEntryPoint GLCompute %4 "main" %15 %110
260 OpExecutionMode %4 LocalSize 1 1 1
261 OpSource ESSL 310
262 OpName %4 "main"
263 OpName %6 "f1("
264 OpName %8 "f2("
265 OpName %12 "x"
266 OpName %15 "gl_GlobalInvocationID"
267 OpName %20 "z"
268 OpName %26 "i"
269 OpName %40 "BufferOut"
270 OpMemberName %40 0 "o_uv4"
271 OpMemberName %40 1 "o_v3"
272 OpMemberName %40 2 "o_i"
273 OpName %42 ""
274 OpName %63 "image2"
275 OpName %79 "image"
276 OpName %89 "i"
277 OpName %110 "gl_LocalInvocationID"
278 OpName %127 "BufferIn"
279 OpMemberName %127 0 "i_u"
280 OpMemberName %127 1 "i_v4"
281 OpMemberName %127 2 "i_f"
282 OpName %129 ""
283 OpDecorate %15 BuiltIn GlobalInvocationId
284 OpMemberDecorate %40 0 Offset 0
285 OpMemberDecorate %40 1 Offset 16
286 OpMemberDecorate %40 2 Offset 28
287 OpDecorate %40 BufferBlock
288 OpDecorate %42 DescriptorSet 0
289 OpDecorate %42 Binding 1
290 OpDecorate %63 DescriptorSet 0
291 OpDecorate %63 Binding 3
292 OpDecorate %79 DescriptorSet 0
293 OpDecorate %79 Binding 2
294 OpDecorate %110 BuiltIn LocalInvocationId
295 OpMemberDecorate %127 0 Offset 0
296 OpMemberDecorate %127 1 RowMajor
297 OpMemberDecorate %127 1 Offset 16
298 OpMemberDecorate %127 1 MatrixStride 16
299 OpMemberDecorate %127 2 Offset 80
300 OpDecorate %127 Block
301 OpDecorate %129 DescriptorSet 0
302 OpDecorate %129 Binding 0
303 %2 = OpTypeVoid
304 %3 = OpTypeFunction %2
305 %10 = OpTypeInt 32 0
306 %11 = OpTypePointer Function %10
307 %13 = OpTypeVector %10 3
308 %14 = OpTypePointer Input %13
309 %15 = OpVariable %14 Input
310 %16 = OpConstant %10 0
311 %17 = OpTypePointer Input %10
312 %21 = OpConstant %10 1
313 %24 = OpTypeInt 32 1
314 %25 = OpTypePointer Function %24
315 %27 = OpConstant %24 0
316 %34 = OpConstant %24 2
317 %35 = OpTypeBool
318 %37 = OpTypeVector %10 4
319 %38 = OpTypeFloat 32
320 %39 = OpTypeVector %38 3
321 %40 = OpTypeStruct %37 %39 %24
322 %41 = OpTypePointer Uniform %40
323 %42 = OpVariable %41 Uniform
324 %46 = OpTypeVector %10 2
325 %48 = OpTypePointer Uniform %37
326 %53 = OpTypePointer Uniform %10
327 %59 = OpConstant %24 1
328 %61 = OpTypeImage %24 2D 0 0 0 2 R32i
329 %62 = OpTypePointer UniformConstant %61
330 %63 = OpVariable %62 UniformConstant
331 %69 = OpTypeVector %24 2
332 %71 = OpTypeVector %24 4
333 %74 = OpTypePointer Uniform %24
334 %76 = OpConstant %10 2
335 %77 = OpConstant %10 3400
336 %78 = OpConstant %10 264
337 %79 = OpVariable %62 UniformConstant
338 %96 = OpConstant %24 3
339 %103 = OpConstantComposite %69 %27 %27
340 %107 = OpTypePointer Uniform %38
341 %110 = OpVariable %14 Input
342 %113 = OpTypeVector %38 2
343 %125 = OpTypeVector %38 4
344 %126 = OpTypeMatrix %125 4
345 %127 = OpTypeStruct %10 %126 %38
346 %128 = OpTypePointer Uniform %127
347 %129 = OpVariable %128 Uniform
348 %4 = OpFunction %2 None %3
349 %5 = OpLabel
350 %123 = OpFunctionCall %2 %8
351 %124 = OpFunctionCall %2 %6
352 OpReturn
353 OpFunctionEnd
354 %6 = OpFunction %2 None %3
355 %7 = OpLabel
356 %12 = OpVariable %11 Function
357 %20 = OpVariable %11 Function
358 %26 = OpVariable %25 Function
359 %18 = OpAccessChain %17 %15 %16
360 %19 = OpLoad %10 %18
361 OpStore %12 %19
362 %22 = OpAccessChain %17 %15 %21
363 %23 = OpLoad %10 %22
364 OpStore %20 %23
365 OpStore %26 %27
366 OpBranch %28
367 %28 = OpLabel
368 OpLoopMerge %30 %31 None
369 OpBranch %32
370 %32 = OpLabel
371 %33 = OpLoad %24 %26
372 %36 = OpSLessThan %35 %33 %34
373 OpBranchConditional %36 %29 %30
374 %29 = OpLabel
375 %43 = OpLoad %10 %12
376 %44 = OpLoad %10 %20
377 %45 = OpIAdd %10 %43 %44
378 %47 = OpCompositeConstruct %46 %45 %45
379 %49 = OpAccessChain %48 %42 %27
380 %50 = OpLoad %37 %49
381 %51 = OpVectorShuffle %46 %50 %50 0 1
382 %52 = OpIAdd %46 %51 %47
383 %54 = OpAccessChain %53 %42 %27 %16
384 %55 = OpCompositeExtract %10 %52 0
385 OpStore %54 %55
386 %56 = OpAccessChain %53 %42 %27 %21
387 %57 = OpCompositeExtract %10 %52 1
388 OpStore %56 %57
389 OpBranch %31
390 %31 = OpLabel
391 %58 = OpLoad %24 %26
392 %60 = OpIAdd %24 %58 %59
393 OpStore %26 %60
394 OpBranch %28
395 %30 = OpLabel
396 %64 = OpLoad %61 %63
397 %65 = OpLoad %10 %12
398 %66 = OpBitcast %24 %65
399 %67 = OpLoad %10 %20
400 %68 = OpBitcast %24 %67
401 %70 = OpCompositeConstruct %69 %66 %68
402 %72 = OpImageRead %71 %64 %70
403 %73 = OpCompositeExtract %24 %72 1
404 %75 = OpAccessChain %74 %42 %34
405 OpStore %75 %73
406 OpMemoryBarrier %76 %77
407 OpControlBarrier %76 %76 %78
408 %80 = OpLoad %61 %79
409 %81 = OpLoad %10 %20
410 %82 = OpBitcast %24 %81
411 %83 = OpLoad %10 %12
412 %84 = OpBitcast %24 %83
413 %85 = OpCompositeConstruct %69 %82 %84
414 %86 = OpAccessChain %74 %42 %34
415 %87 = OpLoad %24 %86
416 %88 = OpCompositeConstruct %71 %87 %27 %27 %27
417 OpImageWrite %80 %85 %88
418 OpReturn
419 OpFunctionEnd
420 %8 = OpFunction %2 None %3
421 %9 = OpLabel
422 %89 = OpVariable %25 Function
423 OpStore %89 %27
424 OpBranch %90
425 %90 = OpLabel
426 OpLoopMerge %92 %93 None
427 OpBranch %94
428 %94 = OpLabel
429 %95 = OpLoad %24 %89
430 %97 = OpSLessThan %35 %95 %96
431 OpBranchConditional %97 %91 %92
432 %91 = OpLabel
433 %98 = OpLoad %24 %89
434 %99 = OpIEqual %35 %98 %27
435 OpSelectionMerge %101 None
436 OpBranchConditional %99 %100 %109
437 %100 = OpLabel
438 %102 = OpLoad %61 %63
439 %104 = OpImageRead %71 %102 %103
440 %105 = OpCompositeExtract %24 %104 0
441 %106 = OpConvertSToF %38 %105
442 %108 = OpAccessChain %107 %42 %59 %16
443 OpStore %108 %106
444 OpBranch %101
445 %109 = OpLabel
446 %111 = OpLoad %13 %110
447 %112 = OpConvertUToF %39 %111
448 %114 = OpCompositeExtract %38 %112 0
449 %115 = OpCompositeExtract %38 %112 1
450 %116 = OpCompositeConstruct %113 %114 %115
451 %117 = OpAccessChain %107 %42 %59 %21
452 %118 = OpCompositeExtract %38 %116 0
453 OpStore %117 %118
454 %119 = OpAccessChain %107 %42 %59 %76
455 %120 = OpCompositeExtract %38 %116 1
456 OpStore %119 %120
457 OpBranch %101
458 %101 = OpLabel
459 OpBranch %93
460 %93 = OpLabel
461 %121 = OpLoad %24 %89
462 %122 = OpIAdd %24 %121 %59
463 OpStore %89 %122
464 OpBranch %90
465 %92 = OpLabel
466 OpReturn
467 OpFunctionEnd
468
469 )";
470
TEST(DiffTest,LargeFunctionsLargeDiffs)471 TEST(DiffTest, LargeFunctionsLargeDiffs) {
472 constexpr char kDiff[] = R"( ; SPIR-V
473 ; Version: 1.6
474 ; Generator: Khronos SPIR-V Tools Assembler; 0
475 -; Bound: 138
476 +; Bound: 190
477 ; Schema: 0
478 OpCapability Shader
479 %1 = OpExtInstImport "GLSL.std.450"
480 OpMemoryModel Logical GLSL450
481 -OpEntryPoint GLCompute %4 "main" %15
482 +OpEntryPoint GLCompute %4 "main" %138 %15
483 OpExecutionMode %4 LocalSize 1 1 1
484 OpSource ESSL 310
485 OpName %4 "main"
486 OpName %6 "f1("
487 OpName %8 "f2("
488 OpName %12 "x"
489 +OpName %138 "gl_GlobalInvocationID"
490 OpName %15 "gl_LocalInvocationID"
491 -OpName %20 "y"
492 +OpName %20 "z"
493 OpName %27 "image"
494 -OpName %44 "sum"
495 +OpName %44 "i"
496 -OpName %46 "i"
497 -OpName %56 "j"
498 OpName %80 "BufferOut"
499 OpMemberName %80 0 "o_uv4"
500 OpMemberName %80 1 "o_v3"
501 OpMemberName %80 2 "o_i"
502 OpName %82 ""
503 OpName %88 "BufferIn"
504 OpMemberName %88 0 "i_u"
505 OpMemberName %88 1 "i_v4"
506 OpMemberName %88 2 "i_f"
507 OpName %90 ""
508 OpName %101 "i"
509 OpName %128 "image2"
510 +OpDecorate %138 BuiltIn GlobalInvocationId
511 OpDecorate %15 BuiltIn LocalInvocationId
512 OpDecorate %27 DescriptorSet 0
513 OpDecorate %27 Binding 2
514 OpMemberDecorate %80 0 Offset 0
515 OpMemberDecorate %80 1 Offset 16
516 OpMemberDecorate %80 2 Offset 28
517 OpDecorate %80 BufferBlock
518 OpDecorate %82 DescriptorSet 0
519 OpDecorate %82 Binding 1
520 OpMemberDecorate %88 0 Offset 0
521 OpMemberDecorate %88 1 RowMajor
522 OpMemberDecorate %88 1 Offset 16
523 OpMemberDecorate %88 1 MatrixStride 16
524 OpMemberDecorate %88 2 Offset 80
525 OpDecorate %88 Block
526 OpDecorate %90 DescriptorSet 0
527 OpDecorate %90 Binding 0
528 OpDecorate %128 DescriptorSet 0
529 OpDecorate %128 Binding 3
530 %2 = OpTypeVoid
531 %3 = OpTypeFunction %2
532 %10 = OpTypeInt 32 0
533 %11 = OpTypePointer Function %10
534 %13 = OpTypeVector %10 3
535 %14 = OpTypePointer Input %13
536 +%138 = OpVariable %14 Input
537 %15 = OpVariable %14 Input
538 %16 = OpConstant %10 0
539 %17 = OpTypePointer Input %10
540 %21 = OpConstant %10 1
541 %24 = OpTypeInt 32 1
542 %25 = OpTypeImage %24 2D 0 0 0 2 R32i
543 %26 = OpTypePointer UniformConstant %25
544 %27 = OpVariable %26 UniformConstant
545 %29 = OpTypeVector %10 2
546 %32 = OpTypeVector %24 2
547 %38 = OpTypeVector %24 4
548 %40 = OpConstant %10 2
549 %41 = OpConstant %10 3400
550 %42 = OpConstant %10 264
551 %43 = OpTypePointer Function %24
552 %45 = OpConstant %24 0
553 +%149 = OpTypePointer Uniform %10
554 %53 = OpConstant %24 2
555 %54 = OpTypeBool
556 %73 = OpConstant %24 1
557 %77 = OpTypeVector %10 4
558 %78 = OpTypeFloat 32
559 %79 = OpTypeVector %78 3
560 %80 = OpTypeStruct %77 %79 %24
561 %81 = OpTypePointer Uniform %80
562 %82 = OpVariable %81 Uniform
563 %84 = OpTypePointer Uniform %24
564 %86 = OpTypeVector %78 4
565 %87 = OpTypeMatrix %86 4
566 %88 = OpTypeStruct %10 %87 %78
567 %89 = OpTypePointer Uniform %88
568 %90 = OpVariable %89 Uniform
569 -%91 = OpTypePointer Uniform %87
570 +%179 = OpTypeVector %78 2
571 %94 = OpTypePointer Uniform %77
572 %108 = OpConstant %24 3
573 -%110 = OpTypePointer Uniform %79
574 %113 = OpTypePointer Uniform %78
575 %128 = OpVariable %26 UniformConstant
576 %130 = OpConstantComposite %32 %45 %45
577 %4 = OpFunction %2 None %3
578 %5 = OpLabel
579 -%136 = OpFunctionCall %2 %6
580 %137 = OpFunctionCall %2 %8
581 +%189 = OpFunctionCall %2 %6
582 OpReturn
583 OpFunctionEnd
584 %6 = OpFunction %2 None %3
585 %7 = OpLabel
586 %12 = OpVariable %11 Function
587 %20 = OpVariable %11 Function
588 %44 = OpVariable %43 Function
589 -%46 = OpVariable %43 Function
590 -%56 = OpVariable %43 Function
591 -%18 = OpAccessChain %17 %15 %16
592 +%139 = OpAccessChain %17 %138 %16
593 -%19 = OpLoad %10 %18
594 +%19 = OpLoad %10 %139
595 OpStore %12 %19
596 -%22 = OpAccessChain %17 %15 %21
597 +%140 = OpAccessChain %17 %138 %21
598 -%23 = OpLoad %10 %22
599 +%23 = OpLoad %10 %140
600 OpStore %20 %23
601 -%28 = OpLoad %25 %27
602 -%30 = OpLoad %13 %15
603 -%31 = OpVectorShuffle %29 %30 %30 0 1
604 -%33 = OpBitcast %32 %31
605 -%34 = OpLoad %10 %12
606 -%35 = OpLoad %10 %20
607 -%36 = OpIAdd %10 %34 %35
608 -%37 = OpBitcast %24 %36
609 -%39 = OpCompositeConstruct %38 %37 %37 %37 %37
610 -OpImageWrite %28 %33 %39
611 -OpMemoryBarrier %40 %41
612 -OpControlBarrier %40 %40 %42
613 OpStore %44 %45
614 -OpStore %46 %45
615 OpBranch %47
616 %47 = OpLabel
617 -OpLoopMerge %49 %50 None
618 +OpLoopMerge %49 %59 None
619 OpBranch %51
620 %51 = OpLabel
621 -%52 = OpLoad %24 %46
622 +%52 = OpLoad %24 %44
623 %55 = OpSLessThan %54 %52 %53
624 OpBranchConditional %55 %48 %49
625 %48 = OpLabel
626 -OpStore %56 %45
627 -OpBranch %57
628 -%57 = OpLabel
629 -OpLoopMerge %59 %60 None
630 -OpBranch %61
631 -%61 = OpLabel
632 -%62 = OpLoad %24 %56
633 -%63 = OpSLessThan %54 %62 %53
634 -OpBranchConditional %63 %58 %59
635 -%58 = OpLabel
636 -%64 = OpLoad %25 %27
637 -%65 = OpLoad %24 %46
638 -%66 = OpLoad %24 %56
639 -%67 = OpCompositeConstruct %32 %65 %66
640 -%68 = OpImageRead %38 %64 %67
641 -%69 = OpCompositeExtract %24 %68 0
642 -%70 = OpLoad %24 %44
643 -%71 = OpIMul %24 %70 %69
644 +%141 = OpLoad %10 %12
645 +%142 = OpLoad %10 %20
646 +%143 = OpIAdd %10 %141 %142
647 +%144 = OpCompositeConstruct %29 %143 %143
648 +%145 = OpAccessChain %94 %82 %45
649 +%146 = OpLoad %77 %145
650 +%147 = OpVectorShuffle %29 %146 %146 0 1
651 +%148 = OpIAdd %29 %147 %144
652 +%150 = OpAccessChain %149 %82 %45 %16
653 +%151 = OpCompositeExtract %10 %148 0
654 -OpStore %44 %71
655 +OpStore %150 %151
656 -OpBranch %60
657 -%60 = OpLabel
658 -%72 = OpLoad %24 %56
659 -%74 = OpIAdd %24 %72 %73
660 +%152 = OpAccessChain %149 %82 %45 %21
661 +%153 = OpCompositeExtract %10 %148 1
662 -OpStore %56 %74
663 +OpStore %152 %153
664 -OpBranch %57
665 +OpBranch %59
666 %59 = OpLabel
667 -OpBranch %50
668 -%50 = OpLabel
669 -%75 = OpLoad %24 %46
670 +%75 = OpLoad %24 %44
671 %76 = OpIAdd %24 %75 %73
672 -OpStore %46 %76
673 +OpStore %44 %76
674 OpBranch %47
675 %49 = OpLabel
676 +%154 = OpLoad %25 %128
677 +%155 = OpLoad %10 %12
678 +%156 = OpBitcast %24 %155
679 +%157 = OpLoad %10 %20
680 +%158 = OpBitcast %24 %157
681 +%159 = OpCompositeConstruct %32 %156 %158
682 +%160 = OpImageRead %38 %154 %159
683 +%161 = OpCompositeExtract %24 %160 1
684 +%162 = OpAccessChain %84 %82 %53
685 +OpStore %162 %161
686 OpMemoryBarrier %40 %41
687 OpControlBarrier %40 %40 %42
688 -%83 = OpLoad %24 %44
689 +%163 = OpLoad %25 %27
690 +%164 = OpLoad %10 %20
691 +%165 = OpBitcast %24 %164
692 +%166 = OpLoad %10 %12
693 +%167 = OpBitcast %24 %166
694 +%168 = OpCompositeConstruct %32 %165 %167
695 %85 = OpAccessChain %84 %82 %53
696 -OpStore %85 %83
697 +%169 = OpLoad %24 %85
698 +%170 = OpCompositeConstruct %38 %169 %45 %45 %45
699 +OpImageWrite %163 %168 %170
700 OpReturn
701 OpFunctionEnd
702 %8 = OpFunction %2 None %3
703 %9 = OpLabel
704 %101 = OpVariable %43 Function
705 -%92 = OpAccessChain %91 %90 %73
706 -%93 = OpLoad %87 %92
707 -%95 = OpAccessChain %94 %82 %45
708 -%96 = OpLoad %77 %95
709 -%97 = OpConvertUToF %86 %96
710 -%98 = OpMatrixTimesVector %86 %93 %97
711 -%99 = OpConvertFToU %77 %98
712 -%100 = OpAccessChain %94 %82 %45
713 -OpStore %100 %99
714 +OpStore %101 %45
715 -OpStore %101 %45
716 OpBranch %102
717 %102 = OpLabel
718 -OpLoopMerge %104 %105 None
719 +OpLoopMerge %171 %172 None
720 OpBranch %106
721 %106 = OpLabel
722 %107 = OpLoad %24 %101
723 %109 = OpSLessThan %54 %107 %108
724 -OpBranchConditional %109 %103 %104
725 +OpBranchConditional %109 %103 %171
726 %103 = OpLabel
727 -%111 = OpAccessChain %110 %82 %73
728 -%112 = OpLoad %79 %111
729 -%114 = OpAccessChain %113 %90 %53
730 -%115 = OpLoad %78 %114
731 -%116 = OpVectorTimesScalar %79 %112 %115
732 -%117 = OpConvertFToU %13 %116
733 -%118 = OpCompositeExtract %10 %117 0
734 -%119 = OpCompositeExtract %10 %117 1
735 -%120 = OpCompositeExtract %10 %117 2
736 -%121 = OpCompositeConstruct %77 %118 %119 %120 %16
737 -%122 = OpAccessChain %94 %82 %45
738 -%123 = OpLoad %77 %122
739 -%124 = OpIAdd %77 %123 %121
740 -%125 = OpAccessChain %94 %82 %45
741 -OpStore %125 %124
742 -OpBranch %105
743 -%105 = OpLabel
744 %126 = OpLoad %24 %101
745 -%127 = OpIAdd %24 %126 %73
746 +%173 = OpIEqual %54 %126 %45
747 +OpSelectionMerge %174 None
748 +OpBranchConditional %173 %104 %176
749 +%176 = OpLabel
750 +%177 = OpLoad %13 %15
751 +%178 = OpConvertUToF %79 %177
752 +%180 = OpCompositeExtract %78 %178 0
753 +%181 = OpCompositeExtract %78 %178 1
754 +%182 = OpCompositeConstruct %179 %180 %181
755 +%183 = OpAccessChain %113 %82 %73 %21
756 +%184 = OpCompositeExtract %78 %182 0
757 -OpStore %101 %127
758 +OpStore %183 %184
759 +%185 = OpAccessChain %113 %82 %73 %40
760 +%186 = OpCompositeExtract %78 %182 1
761 +OpStore %185 %186
762 -OpBranch %102
763 +OpBranch %174
764 %104 = OpLabel
765 -OpMemoryBarrier %40 %41
766 -OpControlBarrier %40 %40 %42
767 %129 = OpLoad %25 %128
768 %131 = OpImageRead %38 %129 %130
769 %132 = OpCompositeExtract %24 %131 0
770 %133 = OpConvertSToF %78 %132
771 -%134 = OpCompositeConstruct %79 %133 %133 %133
772 -%135 = OpAccessChain %110 %82 %73
773 +%175 = OpAccessChain %113 %82 %73 %16
774 -OpStore %135 %134
775 +OpStore %175 %133
776 +OpBranch %174
777 +%174 = OpLabel
778 +OpBranch %172
779 +%172 = OpLabel
780 +%187 = OpLoad %24 %101
781 +%188 = OpIAdd %24 %187 %73
782 +OpStore %101 %188
783 +OpBranch %102
784 +%171 = OpLabel
785 OpReturn
786 OpFunctionEnd
787 )";
788 Options options;
789 DoStringDiffTest(kSrc, kDst, kDiff, options);
790 }
791
TEST(DiffTest,LargeFunctionsLargeDiffsNoDebug)792 TEST(DiffTest, LargeFunctionsLargeDiffsNoDebug) {
793 constexpr char kSrcNoDebug[] = R"( OpCapability Shader
794 %1 = OpExtInstImport "GLSL.std.450"
795 OpMemoryModel Logical GLSL450
796 OpEntryPoint GLCompute %4 "main" %15
797 OpExecutionMode %4 LocalSize 1 1 1
798 OpSource ESSL 310
799 OpDecorate %15 BuiltIn LocalInvocationId
800 OpDecorate %27 DescriptorSet 0
801 OpDecorate %27 Binding 2
802 OpMemberDecorate %80 0 Offset 0
803 OpMemberDecorate %80 1 Offset 16
804 OpMemberDecorate %80 2 Offset 28
805 OpDecorate %80 BufferBlock
806 OpDecorate %82 DescriptorSet 0
807 OpDecorate %82 Binding 1
808 OpMemberDecorate %88 0 Offset 0
809 OpMemberDecorate %88 1 RowMajor
810 OpMemberDecorate %88 1 Offset 16
811 OpMemberDecorate %88 1 MatrixStride 16
812 OpMemberDecorate %88 2 Offset 80
813 OpDecorate %88 Block
814 OpDecorate %90 DescriptorSet 0
815 OpDecorate %90 Binding 0
816 OpDecorate %128 DescriptorSet 0
817 OpDecorate %128 Binding 3
818 %2 = OpTypeVoid
819 %3 = OpTypeFunction %2
820 %10 = OpTypeInt 32 0
821 %11 = OpTypePointer Function %10
822 %13 = OpTypeVector %10 3
823 %14 = OpTypePointer Input %13
824 %15 = OpVariable %14 Input
825 %16 = OpConstant %10 0
826 %17 = OpTypePointer Input %10
827 %21 = OpConstant %10 1
828 %24 = OpTypeInt 32 1
829 %25 = OpTypeImage %24 2D 0 0 0 2 R32i
830 %26 = OpTypePointer UniformConstant %25
831 %27 = OpVariable %26 UniformConstant
832 %29 = OpTypeVector %10 2
833 %32 = OpTypeVector %24 2
834 %38 = OpTypeVector %24 4
835 %40 = OpConstant %10 2
836 %41 = OpConstant %10 3400
837 %42 = OpConstant %10 264
838 %43 = OpTypePointer Function %24
839 %45 = OpConstant %24 0
840 %53 = OpConstant %24 2
841 %54 = OpTypeBool
842 %73 = OpConstant %24 1
843 %77 = OpTypeVector %10 4
844 %78 = OpTypeFloat 32
845 %79 = OpTypeVector %78 3
846 %80 = OpTypeStruct %77 %79 %24
847 %81 = OpTypePointer Uniform %80
848 %82 = OpVariable %81 Uniform
849 %84 = OpTypePointer Uniform %24
850 %86 = OpTypeVector %78 4
851 %87 = OpTypeMatrix %86 4
852 %88 = OpTypeStruct %10 %87 %78
853 %89 = OpTypePointer Uniform %88
854 %90 = OpVariable %89 Uniform
855 %91 = OpTypePointer Uniform %87
856 %94 = OpTypePointer Uniform %77
857 %108 = OpConstant %24 3
858 %110 = OpTypePointer Uniform %79
859 %113 = OpTypePointer Uniform %78
860 %128 = OpVariable %26 UniformConstant
861 %130 = OpConstantComposite %32 %45 %45
862 %4 = OpFunction %2 None %3
863 %5 = OpLabel
864 %136 = OpFunctionCall %2 %6
865 %137 = OpFunctionCall %2 %8
866 OpReturn
867 OpFunctionEnd
868 %6 = OpFunction %2 None %3
869 %7 = OpLabel
870 %12 = OpVariable %11 Function
871 %20 = OpVariable %11 Function
872 %44 = OpVariable %43 Function
873 %46 = OpVariable %43 Function
874 %56 = OpVariable %43 Function
875 %18 = OpAccessChain %17 %15 %16
876 %19 = OpLoad %10 %18
877 OpStore %12 %19
878 %22 = OpAccessChain %17 %15 %21
879 %23 = OpLoad %10 %22
880 OpStore %20 %23
881 %28 = OpLoad %25 %27
882 %30 = OpLoad %13 %15
883 %31 = OpVectorShuffle %29 %30 %30 0 1
884 %33 = OpBitcast %32 %31
885 %34 = OpLoad %10 %12
886 %35 = OpLoad %10 %20
887 %36 = OpIAdd %10 %34 %35
888 %37 = OpBitcast %24 %36
889 %39 = OpCompositeConstruct %38 %37 %37 %37 %37
890 OpImageWrite %28 %33 %39
891 OpMemoryBarrier %40 %41
892 OpControlBarrier %40 %40 %42
893 OpStore %44 %45
894 OpStore %46 %45
895 OpBranch %47
896 %47 = OpLabel
897 OpLoopMerge %49 %50 None
898 OpBranch %51
899 %51 = OpLabel
900 %52 = OpLoad %24 %46
901 %55 = OpSLessThan %54 %52 %53
902 OpBranchConditional %55 %48 %49
903 %48 = OpLabel
904 OpStore %56 %45
905 OpBranch %57
906 %57 = OpLabel
907 OpLoopMerge %59 %60 None
908 OpBranch %61
909 %61 = OpLabel
910 %62 = OpLoad %24 %56
911 %63 = OpSLessThan %54 %62 %53
912 OpBranchConditional %63 %58 %59
913 %58 = OpLabel
914 %64 = OpLoad %25 %27
915 %65 = OpLoad %24 %46
916 %66 = OpLoad %24 %56
917 %67 = OpCompositeConstruct %32 %65 %66
918 %68 = OpImageRead %38 %64 %67
919 %69 = OpCompositeExtract %24 %68 0
920 %70 = OpLoad %24 %44
921 %71 = OpIMul %24 %70 %69
922 OpStore %44 %71
923 OpBranch %60
924 %60 = OpLabel
925 %72 = OpLoad %24 %56
926 %74 = OpIAdd %24 %72 %73
927 OpStore %56 %74
928 OpBranch %57
929 %59 = OpLabel
930 OpBranch %50
931 %50 = OpLabel
932 %75 = OpLoad %24 %46
933 %76 = OpIAdd %24 %75 %73
934 OpStore %46 %76
935 OpBranch %47
936 %49 = OpLabel
937 OpMemoryBarrier %40 %41
938 OpControlBarrier %40 %40 %42
939 %83 = OpLoad %24 %44
940 %85 = OpAccessChain %84 %82 %53
941 OpStore %85 %83
942 OpReturn
943 OpFunctionEnd
944 %8 = OpFunction %2 None %3
945 %9 = OpLabel
946 %101 = OpVariable %43 Function
947 %92 = OpAccessChain %91 %90 %73
948 %93 = OpLoad %87 %92
949 %95 = OpAccessChain %94 %82 %45
950 %96 = OpLoad %77 %95
951 %97 = OpConvertUToF %86 %96
952 %98 = OpMatrixTimesVector %86 %93 %97
953 %99 = OpConvertFToU %77 %98
954 %100 = OpAccessChain %94 %82 %45
955 OpStore %100 %99
956 OpStore %101 %45
957 OpBranch %102
958 %102 = OpLabel
959 OpLoopMerge %104 %105 None
960 OpBranch %106
961 %106 = OpLabel
962 %107 = OpLoad %24 %101
963 %109 = OpSLessThan %54 %107 %108
964 OpBranchConditional %109 %103 %104
965 %103 = OpLabel
966 %111 = OpAccessChain %110 %82 %73
967 %112 = OpLoad %79 %111
968 %114 = OpAccessChain %113 %90 %53
969 %115 = OpLoad %78 %114
970 %116 = OpVectorTimesScalar %79 %112 %115
971 %117 = OpConvertFToU %13 %116
972 %118 = OpCompositeExtract %10 %117 0
973 %119 = OpCompositeExtract %10 %117 1
974 %120 = OpCompositeExtract %10 %117 2
975 %121 = OpCompositeConstruct %77 %118 %119 %120 %16
976 %122 = OpAccessChain %94 %82 %45
977 %123 = OpLoad %77 %122
978 %124 = OpIAdd %77 %123 %121
979 %125 = OpAccessChain %94 %82 %45
980 OpStore %125 %124
981 OpBranch %105
982 %105 = OpLabel
983 %126 = OpLoad %24 %101
984 %127 = OpIAdd %24 %126 %73
985 OpStore %101 %127
986 OpBranch %102
987 %104 = OpLabel
988 OpMemoryBarrier %40 %41
989 OpControlBarrier %40 %40 %42
990 %129 = OpLoad %25 %128
991 %131 = OpImageRead %38 %129 %130
992 %132 = OpCompositeExtract %24 %131 0
993 %133 = OpConvertSToF %78 %132
994 %134 = OpCompositeConstruct %79 %133 %133 %133
995 %135 = OpAccessChain %110 %82 %73
996 OpStore %135 %134
997 OpReturn
998 OpFunctionEnd
999
1000 )";
1001 constexpr char kDstNoDebug[] = R"( OpCapability Shader
1002 %1 = OpExtInstImport "GLSL.std.450"
1003 OpMemoryModel Logical GLSL450
1004 OpEntryPoint GLCompute %4 "main" %15 %110
1005 OpExecutionMode %4 LocalSize 1 1 1
1006 OpSource ESSL 310
1007 OpDecorate %15 BuiltIn GlobalInvocationId
1008 OpMemberDecorate %40 0 Offset 0
1009 OpMemberDecorate %40 1 Offset 16
1010 OpMemberDecorate %40 2 Offset 28
1011 OpDecorate %40 BufferBlock
1012 OpDecorate %42 DescriptorSet 0
1013 OpDecorate %42 Binding 1
1014 OpDecorate %63 DescriptorSet 0
1015 OpDecorate %63 Binding 3
1016 OpDecorate %79 DescriptorSet 0
1017 OpDecorate %79 Binding 2
1018 OpDecorate %110 BuiltIn LocalInvocationId
1019 OpMemberDecorate %127 0 Offset 0
1020 OpMemberDecorate %127 1 RowMajor
1021 OpMemberDecorate %127 1 Offset 16
1022 OpMemberDecorate %127 1 MatrixStride 16
1023 OpMemberDecorate %127 2 Offset 80
1024 OpDecorate %127 Block
1025 OpDecorate %129 DescriptorSet 0
1026 OpDecorate %129 Binding 0
1027 %2 = OpTypeVoid
1028 %3 = OpTypeFunction %2
1029 %10 = OpTypeInt 32 0
1030 %11 = OpTypePointer Function %10
1031 %13 = OpTypeVector %10 3
1032 %14 = OpTypePointer Input %13
1033 %15 = OpVariable %14 Input
1034 %16 = OpConstant %10 0
1035 %17 = OpTypePointer Input %10
1036 %21 = OpConstant %10 1
1037 %24 = OpTypeInt 32 1
1038 %25 = OpTypePointer Function %24
1039 %27 = OpConstant %24 0
1040 %34 = OpConstant %24 2
1041 %35 = OpTypeBool
1042 %37 = OpTypeVector %10 4
1043 %38 = OpTypeFloat 32
1044 %39 = OpTypeVector %38 3
1045 %40 = OpTypeStruct %37 %39 %24
1046 %41 = OpTypePointer Uniform %40
1047 %42 = OpVariable %41 Uniform
1048 %46 = OpTypeVector %10 2
1049 %48 = OpTypePointer Uniform %37
1050 %53 = OpTypePointer Uniform %10
1051 %59 = OpConstant %24 1
1052 %61 = OpTypeImage %24 2D 0 0 0 2 R32i
1053 %62 = OpTypePointer UniformConstant %61
1054 %63 = OpVariable %62 UniformConstant
1055 %69 = OpTypeVector %24 2
1056 %71 = OpTypeVector %24 4
1057 %74 = OpTypePointer Uniform %24
1058 %76 = OpConstant %10 2
1059 %77 = OpConstant %10 3400
1060 %78 = OpConstant %10 264
1061 %79 = OpVariable %62 UniformConstant
1062 %96 = OpConstant %24 3
1063 %103 = OpConstantComposite %69 %27 %27
1064 %107 = OpTypePointer Uniform %38
1065 %110 = OpVariable %14 Input
1066 %113 = OpTypeVector %38 2
1067 %125 = OpTypeVector %38 4
1068 %126 = OpTypeMatrix %125 4
1069 %127 = OpTypeStruct %10 %126 %38
1070 %128 = OpTypePointer Uniform %127
1071 %129 = OpVariable %128 Uniform
1072 %4 = OpFunction %2 None %3
1073 %5 = OpLabel
1074 %123 = OpFunctionCall %2 %8
1075 %124 = OpFunctionCall %2 %6
1076 OpReturn
1077 OpFunctionEnd
1078 %6 = OpFunction %2 None %3
1079 %7 = OpLabel
1080 %12 = OpVariable %11 Function
1081 %20 = OpVariable %11 Function
1082 %26 = OpVariable %25 Function
1083 %18 = OpAccessChain %17 %15 %16
1084 %19 = OpLoad %10 %18
1085 OpStore %12 %19
1086 %22 = OpAccessChain %17 %15 %21
1087 %23 = OpLoad %10 %22
1088 OpStore %20 %23
1089 OpStore %26 %27
1090 OpBranch %28
1091 %28 = OpLabel
1092 OpLoopMerge %30 %31 None
1093 OpBranch %32
1094 %32 = OpLabel
1095 %33 = OpLoad %24 %26
1096 %36 = OpSLessThan %35 %33 %34
1097 OpBranchConditional %36 %29 %30
1098 %29 = OpLabel
1099 %43 = OpLoad %10 %12
1100 %44 = OpLoad %10 %20
1101 %45 = OpIAdd %10 %43 %44
1102 %47 = OpCompositeConstruct %46 %45 %45
1103 %49 = OpAccessChain %48 %42 %27
1104 %50 = OpLoad %37 %49
1105 %51 = OpVectorShuffle %46 %50 %50 0 1
1106 %52 = OpIAdd %46 %51 %47
1107 %54 = OpAccessChain %53 %42 %27 %16
1108 %55 = OpCompositeExtract %10 %52 0
1109 OpStore %54 %55
1110 %56 = OpAccessChain %53 %42 %27 %21
1111 %57 = OpCompositeExtract %10 %52 1
1112 OpStore %56 %57
1113 OpBranch %31
1114 %31 = OpLabel
1115 %58 = OpLoad %24 %26
1116 %60 = OpIAdd %24 %58 %59
1117 OpStore %26 %60
1118 OpBranch %28
1119 %30 = OpLabel
1120 %64 = OpLoad %61 %63
1121 %65 = OpLoad %10 %12
1122 %66 = OpBitcast %24 %65
1123 %67 = OpLoad %10 %20
1124 %68 = OpBitcast %24 %67
1125 %70 = OpCompositeConstruct %69 %66 %68
1126 %72 = OpImageRead %71 %64 %70
1127 %73 = OpCompositeExtract %24 %72 1
1128 %75 = OpAccessChain %74 %42 %34
1129 OpStore %75 %73
1130 OpMemoryBarrier %76 %77
1131 OpControlBarrier %76 %76 %78
1132 %80 = OpLoad %61 %79
1133 %81 = OpLoad %10 %20
1134 %82 = OpBitcast %24 %81
1135 %83 = OpLoad %10 %12
1136 %84 = OpBitcast %24 %83
1137 %85 = OpCompositeConstruct %69 %82 %84
1138 %86 = OpAccessChain %74 %42 %34
1139 %87 = OpLoad %24 %86
1140 %88 = OpCompositeConstruct %71 %87 %27 %27 %27
1141 OpImageWrite %80 %85 %88
1142 OpReturn
1143 OpFunctionEnd
1144 %8 = OpFunction %2 None %3
1145 %9 = OpLabel
1146 %89 = OpVariable %25 Function
1147 OpStore %89 %27
1148 OpBranch %90
1149 %90 = OpLabel
1150 OpLoopMerge %92 %93 None
1151 OpBranch %94
1152 %94 = OpLabel
1153 %95 = OpLoad %24 %89
1154 %97 = OpSLessThan %35 %95 %96
1155 OpBranchConditional %97 %91 %92
1156 %91 = OpLabel
1157 %98 = OpLoad %24 %89
1158 %99 = OpIEqual %35 %98 %27
1159 OpSelectionMerge %101 None
1160 OpBranchConditional %99 %100 %109
1161 %100 = OpLabel
1162 %102 = OpLoad %61 %63
1163 %104 = OpImageRead %71 %102 %103
1164 %105 = OpCompositeExtract %24 %104 0
1165 %106 = OpConvertSToF %38 %105
1166 %108 = OpAccessChain %107 %42 %59 %16
1167 OpStore %108 %106
1168 OpBranch %101
1169 %109 = OpLabel
1170 %111 = OpLoad %13 %110
1171 %112 = OpConvertUToF %39 %111
1172 %114 = OpCompositeExtract %38 %112 0
1173 %115 = OpCompositeExtract %38 %112 1
1174 %116 = OpCompositeConstruct %113 %114 %115
1175 %117 = OpAccessChain %107 %42 %59 %21
1176 %118 = OpCompositeExtract %38 %116 0
1177 OpStore %117 %118
1178 %119 = OpAccessChain %107 %42 %59 %76
1179 %120 = OpCompositeExtract %38 %116 1
1180 OpStore %119 %120
1181 OpBranch %101
1182 %101 = OpLabel
1183 OpBranch %93
1184 %93 = OpLabel
1185 %121 = OpLoad %24 %89
1186 %122 = OpIAdd %24 %121 %59
1187 OpStore %89 %122
1188 OpBranch %90
1189 %92 = OpLabel
1190 OpReturn
1191 OpFunctionEnd
1192
1193 )";
1194 constexpr char kDiff[] = R"( ; SPIR-V
1195 ; Version: 1.6
1196 ; Generator: Khronos SPIR-V Tools Assembler; 0
1197 -; Bound: 138
1198 +; Bound: 220
1199 ; Schema: 0
1200 OpCapability Shader
1201 %1 = OpExtInstImport "GLSL.std.450"
1202 OpMemoryModel Logical GLSL450
1203 -OpEntryPoint GLCompute %4 "main" %15
1204 +OpEntryPoint GLCompute %4 "main" %143 %15
1205 OpExecutionMode %4 LocalSize 1 1 1
1206 OpSource ESSL 310
1207 +OpDecorate %143 BuiltIn GlobalInvocationId
1208 OpDecorate %15 BuiltIn LocalInvocationId
1209 OpDecorate %27 DescriptorSet 0
1210 OpDecorate %27 Binding 2
1211 OpMemberDecorate %80 0 Offset 0
1212 OpMemberDecorate %80 1 Offset 16
1213 OpMemberDecorate %80 2 Offset 28
1214 OpDecorate %80 BufferBlock
1215 OpDecorate %82 DescriptorSet 0
1216 OpDecorate %82 Binding 1
1217 OpMemberDecorate %88 0 Offset 0
1218 OpMemberDecorate %88 1 RowMajor
1219 OpMemberDecorate %88 1 Offset 16
1220 OpMemberDecorate %88 1 MatrixStride 16
1221 OpMemberDecorate %88 2 Offset 80
1222 OpDecorate %88 Block
1223 OpDecorate %90 DescriptorSet 0
1224 OpDecorate %90 Binding 0
1225 OpDecorate %128 DescriptorSet 0
1226 OpDecorate %128 Binding 3
1227 %2 = OpTypeVoid
1228 %3 = OpTypeFunction %2
1229 %10 = OpTypeInt 32 0
1230 %11 = OpTypePointer Function %10
1231 %13 = OpTypeVector %10 3
1232 %14 = OpTypePointer Input %13
1233 +%143 = OpVariable %14 Input
1234 %15 = OpVariable %14 Input
1235 %16 = OpConstant %10 0
1236 %17 = OpTypePointer Input %10
1237 %21 = OpConstant %10 1
1238 %24 = OpTypeInt 32 1
1239 %25 = OpTypeImage %24 2D 0 0 0 2 R32i
1240 %26 = OpTypePointer UniformConstant %25
1241 %27 = OpVariable %26 UniformConstant
1242 %29 = OpTypeVector %10 2
1243 %32 = OpTypeVector %24 2
1244 %38 = OpTypeVector %24 4
1245 %40 = OpConstant %10 2
1246 %41 = OpConstant %10 3400
1247 %42 = OpConstant %10 264
1248 %43 = OpTypePointer Function %24
1249 %45 = OpConstant %24 0
1250 +%165 = OpTypePointer Uniform %10
1251 %53 = OpConstant %24 2
1252 %54 = OpTypeBool
1253 %73 = OpConstant %24 1
1254 %77 = OpTypeVector %10 4
1255 %78 = OpTypeFloat 32
1256 %79 = OpTypeVector %78 3
1257 %80 = OpTypeStruct %77 %79 %24
1258 %81 = OpTypePointer Uniform %80
1259 %82 = OpVariable %81 Uniform
1260 %84 = OpTypePointer Uniform %24
1261 %86 = OpTypeVector %78 4
1262 %87 = OpTypeMatrix %86 4
1263 %88 = OpTypeStruct %10 %87 %78
1264 %89 = OpTypePointer Uniform %88
1265 %90 = OpVariable %89 Uniform
1266 -%91 = OpTypePointer Uniform %87
1267 +%210 = OpTypeVector %78 2
1268 %94 = OpTypePointer Uniform %77
1269 %108 = OpConstant %24 3
1270 -%110 = OpTypePointer Uniform %79
1271 %113 = OpTypePointer Uniform %78
1272 %128 = OpVariable %26 UniformConstant
1273 %130 = OpConstantComposite %32 %45 %45
1274 %4 = OpFunction %2 None %3
1275 %5 = OpLabel
1276 -%136 = OpFunctionCall %2 %6
1277 +%136 = OpFunctionCall %2 %140
1278 -%137 = OpFunctionCall %2 %8
1279 +%137 = OpFunctionCall %2 %138
1280 OpReturn
1281 OpFunctionEnd
1282 -%6 = OpFunction %2 None %3
1283 -%7 = OpLabel
1284 -%12 = OpVariable %11 Function
1285 -%20 = OpVariable %11 Function
1286 -%44 = OpVariable %43 Function
1287 -%46 = OpVariable %43 Function
1288 -%56 = OpVariable %43 Function
1289 -%18 = OpAccessChain %17 %15 %16
1290 -%19 = OpLoad %10 %18
1291 -OpStore %12 %19
1292 -%22 = OpAccessChain %17 %15 %21
1293 -%23 = OpLoad %10 %22
1294 -OpStore %20 %23
1295 -%28 = OpLoad %25 %27
1296 -%30 = OpLoad %13 %15
1297 -%31 = OpVectorShuffle %29 %30 %30 0 1
1298 -%33 = OpBitcast %32 %31
1299 -%34 = OpLoad %10 %12
1300 -%35 = OpLoad %10 %20
1301 -%36 = OpIAdd %10 %34 %35
1302 -%37 = OpBitcast %24 %36
1303 -%39 = OpCompositeConstruct %38 %37 %37 %37 %37
1304 -OpImageWrite %28 %33 %39
1305 -OpMemoryBarrier %40 %41
1306 -OpControlBarrier %40 %40 %42
1307 -OpStore %44 %45
1308 -OpStore %46 %45
1309 -OpBranch %47
1310 -%47 = OpLabel
1311 -OpLoopMerge %49 %50 None
1312 -OpBranch %51
1313 -%51 = OpLabel
1314 -%52 = OpLoad %24 %46
1315 -%55 = OpSLessThan %54 %52 %53
1316 -OpBranchConditional %55 %48 %49
1317 -%48 = OpLabel
1318 -OpStore %56 %45
1319 -OpBranch %57
1320 -%57 = OpLabel
1321 -OpLoopMerge %59 %60 None
1322 -OpBranch %61
1323 -%61 = OpLabel
1324 -%62 = OpLoad %24 %56
1325 -%63 = OpSLessThan %54 %62 %53
1326 -OpBranchConditional %63 %58 %59
1327 -%58 = OpLabel
1328 -%64 = OpLoad %25 %27
1329 -%65 = OpLoad %24 %46
1330 -%66 = OpLoad %24 %56
1331 -%67 = OpCompositeConstruct %32 %65 %66
1332 -%68 = OpImageRead %38 %64 %67
1333 -%69 = OpCompositeExtract %24 %68 0
1334 -%70 = OpLoad %24 %44
1335 -%71 = OpIMul %24 %70 %69
1336 -OpStore %44 %71
1337 -OpBranch %60
1338 -%60 = OpLabel
1339 -%72 = OpLoad %24 %56
1340 -%74 = OpIAdd %24 %72 %73
1341 -OpStore %56 %74
1342 -OpBranch %57
1343 -%59 = OpLabel
1344 -OpBranch %50
1345 -%50 = OpLabel
1346 -%75 = OpLoad %24 %46
1347 -%76 = OpIAdd %24 %75 %73
1348 -OpStore %46 %76
1349 -OpBranch %47
1350 -%49 = OpLabel
1351 -OpMemoryBarrier %40 %41
1352 -OpControlBarrier %40 %40 %42
1353 -%83 = OpLoad %24 %44
1354 -%85 = OpAccessChain %84 %82 %53
1355 -OpStore %85 %83
1356 -OpReturn
1357 -OpFunctionEnd
1358 -%8 = OpFunction %2 None %3
1359 -%9 = OpLabel
1360 -%101 = OpVariable %43 Function
1361 -%92 = OpAccessChain %91 %90 %73
1362 -%93 = OpLoad %87 %92
1363 -%95 = OpAccessChain %94 %82 %45
1364 -%96 = OpLoad %77 %95
1365 -%97 = OpConvertUToF %86 %96
1366 -%98 = OpMatrixTimesVector %86 %93 %97
1367 -%99 = OpConvertFToU %77 %98
1368 -%100 = OpAccessChain %94 %82 %45
1369 -OpStore %100 %99
1370 -OpStore %101 %45
1371 -OpBranch %102
1372 -%102 = OpLabel
1373 -OpLoopMerge %104 %105 None
1374 -OpBranch %106
1375 -%106 = OpLabel
1376 -%107 = OpLoad %24 %101
1377 -%109 = OpSLessThan %54 %107 %108
1378 -OpBranchConditional %109 %103 %104
1379 -%103 = OpLabel
1380 -%111 = OpAccessChain %110 %82 %73
1381 -%112 = OpLoad %79 %111
1382 -%114 = OpAccessChain %113 %90 %53
1383 -%115 = OpLoad %78 %114
1384 -%116 = OpVectorTimesScalar %79 %112 %115
1385 -%117 = OpConvertFToU %13 %116
1386 -%118 = OpCompositeExtract %10 %117 0
1387 -%119 = OpCompositeExtract %10 %117 1
1388 -%120 = OpCompositeExtract %10 %117 2
1389 -%121 = OpCompositeConstruct %77 %118 %119 %120 %16
1390 -%122 = OpAccessChain %94 %82 %45
1391 -%123 = OpLoad %77 %122
1392 -%124 = OpIAdd %77 %123 %121
1393 -%125 = OpAccessChain %94 %82 %45
1394 -OpStore %125 %124
1395 -OpBranch %105
1396 -%105 = OpLabel
1397 -%126 = OpLoad %24 %101
1398 -%127 = OpIAdd %24 %126 %73
1399 -OpStore %101 %127
1400 -OpBranch %102
1401 -%104 = OpLabel
1402 -OpMemoryBarrier %40 %41
1403 -OpControlBarrier %40 %40 %42
1404 -%129 = OpLoad %25 %128
1405 -%131 = OpImageRead %38 %129 %130
1406 -%132 = OpCompositeExtract %24 %131 0
1407 -%133 = OpConvertSToF %78 %132
1408 -%134 = OpCompositeConstruct %79 %133 %133 %133
1409 -%135 = OpAccessChain %110 %82 %73
1410 -OpStore %135 %134
1411 -OpReturn
1412 -OpFunctionEnd
1413 +%138 = OpFunction %2 None %3
1414 +%139 = OpLabel
1415 +%142 = OpVariable %11 Function
1416 +%146 = OpVariable %11 Function
1417 +%149 = OpVariable %43 Function
1418 +%144 = OpAccessChain %17 %143 %16
1419 +%145 = OpLoad %10 %144
1420 +OpStore %142 %145
1421 +%147 = OpAccessChain %17 %143 %21
1422 +%148 = OpLoad %10 %147
1423 +OpStore %146 %148
1424 +OpStore %149 %45
1425 +OpBranch %150
1426 +%150 = OpLabel
1427 +OpLoopMerge %152 %153 None
1428 +OpBranch %154
1429 +%154 = OpLabel
1430 +%155 = OpLoad %24 %149
1431 +%156 = OpSLessThan %54 %155 %53
1432 +OpBranchConditional %156 %151 %152
1433 +%151 = OpLabel
1434 +%157 = OpLoad %10 %142
1435 +%158 = OpLoad %10 %146
1436 +%159 = OpIAdd %10 %157 %158
1437 +%160 = OpCompositeConstruct %29 %159 %159
1438 +%161 = OpAccessChain %94 %82 %45
1439 +%162 = OpLoad %77 %161
1440 +%163 = OpVectorShuffle %29 %162 %162 0 1
1441 +%164 = OpIAdd %29 %163 %160
1442 +%166 = OpAccessChain %165 %82 %45 %16
1443 +%167 = OpCompositeExtract %10 %164 0
1444 +OpStore %166 %167
1445 +%168 = OpAccessChain %165 %82 %45 %21
1446 +%169 = OpCompositeExtract %10 %164 1
1447 +OpStore %168 %169
1448 +OpBranch %153
1449 +%153 = OpLabel
1450 +%170 = OpLoad %24 %149
1451 +%171 = OpIAdd %24 %170 %73
1452 +OpStore %149 %171
1453 +OpBranch %150
1454 +%152 = OpLabel
1455 +%172 = OpLoad %25 %128
1456 +%173 = OpLoad %10 %142
1457 +%174 = OpBitcast %24 %173
1458 +%175 = OpLoad %10 %146
1459 +%176 = OpBitcast %24 %175
1460 +%177 = OpCompositeConstruct %32 %174 %176
1461 +%178 = OpImageRead %38 %172 %177
1462 +%179 = OpCompositeExtract %24 %178 1
1463 +%180 = OpAccessChain %84 %82 %53
1464 +OpStore %180 %179
1465 +OpMemoryBarrier %40 %41
1466 +OpControlBarrier %40 %40 %42
1467 +%181 = OpLoad %25 %27
1468 +%182 = OpLoad %10 %146
1469 +%183 = OpBitcast %24 %182
1470 +%184 = OpLoad %10 %142
1471 +%185 = OpBitcast %24 %184
1472 +%186 = OpCompositeConstruct %32 %183 %185
1473 +%187 = OpAccessChain %84 %82 %53
1474 +%188 = OpLoad %24 %187
1475 +%189 = OpCompositeConstruct %38 %188 %45 %45 %45
1476 +OpImageWrite %181 %186 %189
1477 +OpReturn
1478 +OpFunctionEnd
1479 +%140 = OpFunction %2 None %3
1480 +%141 = OpLabel
1481 +%190 = OpVariable %43 Function
1482 +OpStore %190 %45
1483 +OpBranch %191
1484 +%191 = OpLabel
1485 +OpLoopMerge %193 %194 None
1486 +OpBranch %195
1487 +%195 = OpLabel
1488 +%196 = OpLoad %24 %190
1489 +%197 = OpSLessThan %54 %196 %108
1490 +OpBranchConditional %197 %192 %193
1491 +%192 = OpLabel
1492 +%198 = OpLoad %24 %190
1493 +%199 = OpIEqual %54 %198 %45
1494 +OpSelectionMerge %201 None
1495 +OpBranchConditional %199 %200 %207
1496 +%207 = OpLabel
1497 +%208 = OpLoad %13 %15
1498 +%209 = OpConvertUToF %79 %208
1499 +%211 = OpCompositeExtract %78 %209 0
1500 +%212 = OpCompositeExtract %78 %209 1
1501 +%213 = OpCompositeConstruct %210 %211 %212
1502 +%214 = OpAccessChain %113 %82 %73 %21
1503 +%215 = OpCompositeExtract %78 %213 0
1504 +OpStore %214 %215
1505 +%216 = OpAccessChain %113 %82 %73 %40
1506 +%217 = OpCompositeExtract %78 %213 1
1507 +OpStore %216 %217
1508 +OpBranch %201
1509 +%200 = OpLabel
1510 +%202 = OpLoad %25 %128
1511 +%203 = OpImageRead %38 %202 %130
1512 +%204 = OpCompositeExtract %24 %203 0
1513 +%205 = OpConvertSToF %78 %204
1514 +%206 = OpAccessChain %113 %82 %73 %16
1515 +OpStore %206 %205
1516 +OpBranch %201
1517 +%201 = OpLabel
1518 +OpBranch %194
1519 +%194 = OpLabel
1520 +%218 = OpLoad %24 %190
1521 +%219 = OpIAdd %24 %218 %73
1522 +OpStore %190 %219
1523 +OpBranch %191
1524 +%193 = OpLabel
1525 +OpReturn
1526 +OpFunctionEnd
1527 )";
1528 Options options;
1529 DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
1530 }
1531
1532 } // namespace
1533 } // namespace diff
1534 } // namespace spvtools
1535