Commit 832c65c3 by Dejan Mircevski

Fix back-branch target for do-while loops.

To ensure back branches always go to a header block, create a header block even for !testFirst loops. Then unify common code between the testFirst/!testFirst cases. Generate the header-block code first, so update golden files. Realize that certain infinite loops generate invalid SPIR-V, so put a TODO to instead abort code generation in such cases. Change-Id: I1e173c8f73daad186cfc666b7d72bd563ed7665d
parent c8fbbab4
...@@ -1342,19 +1342,17 @@ void TGlslangToSpvTraverser::visitConstantUnion(glslang::TIntermConstantUnion* n ...@@ -1342,19 +1342,17 @@ void TGlslangToSpvTraverser::visitConstantUnion(glslang::TIntermConstantUnion* n
bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIntermLoop* node) bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIntermLoop* node)
{ {
auto blocks = builder.makeNewLoop(); auto blocks = builder.makeNewLoop();
builder.createBranch(&blocks.head);
if (node->testFirst() && node->getTest()) { if (node->testFirst() && node->getTest()) {
spv::Block& head = builder.makeNewBlock(); builder.setBuildPoint(&blocks.head);
builder.createBranch(&head);
builder.setBuildPoint(&head);
node->getTest()->traverse(this); node->getTest()->traverse(this);
spv::Id condition = spv::Id condition =
builder.accessChainLoad(convertGlslangToSpvType(node->getTest()->getType())); builder.accessChainLoad(convertGlslangToSpvType(node->getTest()->getType()));
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, spv::LoopControlMaskNone); builder.createLoopMerge(&blocks.merge, &blocks.continue_target, spv::LoopControlMaskNone);
builder.createConditionalBranch(condition, &blocks.body, &blocks.merge); builder.createConditionalBranch(condition, &blocks.body, &blocks.merge);
breakForLoop.push(true);
builder.setBuildPoint(&blocks.body); builder.setBuildPoint(&blocks.body);
breakForLoop.push(true);
if (node->getBody()) if (node->getBody())
node->getBody()->traverse(this); node->getBody()->traverse(this);
builder.createBranch(&blocks.continue_target); builder.createBranch(&blocks.continue_target);
...@@ -1363,8 +1361,14 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn ...@@ -1363,8 +1361,14 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn
builder.setBuildPoint(&blocks.continue_target); builder.setBuildPoint(&blocks.continue_target);
if (node->getTerminal()) if (node->getTerminal())
node->getTerminal()->traverse(this); node->getTerminal()->traverse(this);
builder.createBranch(&head); builder.createBranch(&blocks.head);
} else { } else {
// Spec requires back edges to target header blocks, and every header
// block must dominate its merge block. Create an empty header block
// here to ensure these conditions are met even when body contains
// non-trivial control flow.
builder.setBuildPoint(&blocks.head);
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, spv::LoopControlMaskNone);
builder.createBranch(&blocks.body); builder.createBranch(&blocks.body);
breakForLoop.push(true); breakForLoop.push(true);
...@@ -1381,14 +1385,17 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn ...@@ -1381,14 +1385,17 @@ bool TGlslangToSpvTraverser::visitLoop(glslang::TVisit /* visit */, glslang::TIn
node->getTest()->traverse(this); node->getTest()->traverse(this);
spv::Id condition = spv::Id condition =
builder.accessChainLoad(convertGlslangToSpvType(node->getTest()->getType())); builder.accessChainLoad(convertGlslangToSpvType(node->getTest()->getType()));
builder.createLoopMerge(&blocks.merge, &blocks.continue_target, builder.createConditionalBranch(condition, &blocks.head, &blocks.merge);
spv::LoopControlMaskNone);
builder.createConditionalBranch(condition, &blocks.body, &blocks.merge);
} else { } else {
builder.createBranch(&blocks.body); // TODO: unless there was a break instruction somewhere in the body,
// this is an infinite loop, so we should abort code generation with
// a warning. As it stands now, nothing will jump to the merge
// block, and it may be dropped as unreachable by the SPIR-V dumper.
// That, in turn, will result in a non-existing %ID in the LoopMerge
// above.
builder.createBranch(&blocks.head);
} }
} }
builder.setBuildPoint(&blocks.merge); builder.setBuildPoint(&blocks.merge);
builder.closeLoop(); builder.closeLoop();
return false; return false;
......
...@@ -1763,7 +1763,7 @@ Block& Builder::makeNewBlock() ...@@ -1763,7 +1763,7 @@ Block& Builder::makeNewBlock()
Builder::LoopBlocks& Builder::makeNewLoop() Builder::LoopBlocks& Builder::makeNewLoop()
{ {
loops.push({makeNewBlock(), makeNewBlock(), makeNewBlock()}); loops.push({makeNewBlock(), makeNewBlock(), makeNewBlock(), makeNewBlock()});
return loops.top(); return loops.top();
} }
......
...@@ -374,7 +374,7 @@ public: ...@@ -374,7 +374,7 @@ public:
void endSwitch(std::vector<Block*>& segmentBB); void endSwitch(std::vector<Block*>& segmentBB);
struct LoopBlocks { struct LoopBlocks {
Block &body, &merge, &continue_target; Block &head, &body, &merge, &continue_target;
}; };
// Start a new loop and prepare the builder to generate code for it. Until // Start a new loop and prepare the builder to generate code for it. Until
......
...@@ -48,26 +48,26 @@ Linked vertex stage: ...@@ -48,26 +48,26 @@ Linked vertex stage:
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 13 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None
BranchConditional 17 11 12
11: Label
25: 6(int) Load 8(i) 25: 6(int) Load 8(i)
28: 19(fvec4) Load 27(color) 28: 19(fvec4) Load 27(color)
30: 29(ptr) AccessChain 24(colorOut) 25 30: 29(ptr) AccessChain 24(colorOut) 25
Store 30 28 Store 30 28
Branch 12 Branch 13
11: Label 12: Label
35: 29(ptr) AccessChain 24(colorOut) 34 35: 29(ptr) AccessChain 24(colorOut) 34
36: 19(fvec4) Load 35 36: 19(fvec4) Load 35
Store 33(gl_Position) 36 Store 33(gl_Position) 36
Return Return
12: Label 13: Label
31: 6(int) Load 8(i) 31: 6(int) Load 8(i)
32: 6(int) IAdd 31 9 32: 6(int) IAdd 31 9
Store 8(i) 32 Store 8(i) 32
Branch 13 Branch 10
13: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 11 12 None
BranchConditional 17 10 11
FunctionEnd FunctionEnd
...@@ -5,45 +5,47 @@ Linked vertex stage: ...@@ -5,45 +5,47 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 23 // Id's are bound by 24
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 21 22 EntryPoint Vertex 4 "main" 22 23
Source ESSL 300 Source ESSL 300
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 21 "gl_VertexID" Name 22 "gl_VertexID"
Name 22 "gl_InstanceID" Name 23 "gl_InstanceID"
Decorate 21(gl_VertexID) BuiltIn VertexId Decorate 22(gl_VertexID) BuiltIn VertexId
Decorate 22(gl_InstanceID) BuiltIn InstanceId Decorate 23(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
14: 6(int) Constant 1 15: 6(int) Constant 1
17: 6(int) Constant 10 18: 6(int) Constant 10
18: TypeBool 19: TypeBool
20: TypePointer Input 6(int) 21: TypePointer Input 6(int)
21(gl_VertexID): 20(ptr) Variable Input 22(gl_VertexID): 21(ptr) Variable Input
22(gl_InstanceID): 20(ptr) Variable Input 23(gl_InstanceID): 21(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
13: 6(int) Load 8(i) LoopMerge 12 13 None
15: 6(int) IAdd 13 14 Branch 11
Store 8(i) 15
Branch 12
11: Label 11: Label
Return 14: 6(int) Load 8(i)
16: 6(int) IAdd 14 15
Store 8(i) 16
Branch 13
12: Label 12: Label
16: 6(int) Load 8(i) Return
19: 18(bool) SLessThan 16 17 13: Label
LoopMerge 11 12 None 17: 6(int) Load 8(i)
BranchConditional 19 10 11 20: 19(bool) SLessThan 17 18
BranchConditional 20 10 12
FunctionEnd FunctionEnd
...@@ -5,89 +5,91 @@ Linked vertex stage: ...@@ -5,89 +5,91 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 45 // Id's are bound by 46
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 43 44 EntryPoint Vertex 4 "main" 44 45
Source ESSL 300 Source ESSL 300
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 13 "A" Name 14 "A"
Name 20 "B" Name 21 "B"
Name 23 "C" Name 24 "C"
Name 29 "D" Name 30 "D"
Name 32 "E" Name 33 "E"
Name 34 "F" Name 35 "F"
Name 40 "G" Name 41 "G"
Name 43 "gl_VertexID" Name 44 "gl_VertexID"
Name 44 "gl_InstanceID" Name 45 "gl_InstanceID"
Decorate 43(gl_VertexID) BuiltIn VertexId Decorate 44(gl_VertexID) BuiltIn VertexId
Decorate 44(gl_InstanceID) BuiltIn InstanceId Decorate 45(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
15: 6(int) Constant 2 16: 6(int) Constant 2
16: TypeBool 17: TypeBool
21: 6(int) Constant 1 22: 6(int) Constant 1
25: 6(int) Constant 5 26: 6(int) Constant 5
30: 6(int) Constant 3 31: 6(int) Constant 3
33: 6(int) Constant 42 34: 6(int) Constant 42
35: 6(int) Constant 99 36: 6(int) Constant 99
38: 6(int) Constant 19 39: 6(int) Constant 19
41: 6(int) Constant 12 42: 6(int) Constant 12
42: TypePointer Input 6(int) 43: TypePointer Input 6(int)
43(gl_VertexID): 42(ptr) Variable Input 44(gl_VertexID): 43(ptr) Variable Input
44(gl_InstanceID): 42(ptr) Variable Input 45(gl_InstanceID): 43(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
13(A): 7(ptr) Variable Function 14(A): 7(ptr) Variable Function
20(B): 7(ptr) Variable Function 21(B): 7(ptr) Variable Function
23(C): 7(ptr) Variable Function 24(C): 7(ptr) Variable Function
29(D): 7(ptr) Variable Function 30(D): 7(ptr) Variable Function
32(E): 7(ptr) Variable Function 33(E): 7(ptr) Variable Function
34(F): 7(ptr) Variable Function 35(F): 7(ptr) Variable Function
40(G): 7(ptr) Variable Function 41(G): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
Store 13(A) 9 LoopMerge 12 13 None
14: 6(int) Load 8(i) Branch 11
17: 16(bool) IEqual 14 15
SelectionMerge 19 None
BranchConditional 17 18 19
11: Label 11: Label
Store 40(G) 41 Store 14(A) 9
Return 15: 6(int) Load 8(i)
18: 17(bool) IEqual 15 16
SelectionMerge 20 None
BranchConditional 18 19 20
12: Label 12: Label
36: 6(int) Load 8(i) Store 41(G) 42
37: 6(int) IAdd 36 21 Return
Store 8(i) 37 13: Label
39: 16(bool) SLessThan 37 38 37: 6(int) Load 8(i)
LoopMerge 11 12 None 38: 6(int) IAdd 37 22
BranchConditional 39 10 11 Store 8(i) 38
18: Label 40: 17(bool) SLessThan 38 39
Store 20(B) 21 BranchConditional 40 10 12
Branch 12
22: Label
Store 23(C) 15
Branch 19
19: Label 19: Label
24: 6(int) Load 8(i) Store 21(B) 22
26: 16(bool) IEqual 24 25 Branch 13
SelectionMerge 28 None 23: Label
BranchConditional 26 27 28 Store 24(C) 16
27: Label Branch 20
Store 29(D) 30 20: Label
Branch 11 25: 6(int) Load 8(i)
31: Label 27: 17(bool) IEqual 25 26
Store 32(E) 33 SelectionMerge 29 None
Branch 28 BranchConditional 27 28 29
28: Label 28: Label
Store 34(F) 35 Store 30(D) 31
Branch 12 Branch 12
32: Label
Store 33(E) 34
Branch 29
29: Label
Store 35(F) 36
Branch 13
FunctionEnd FunctionEnd
...@@ -5,7 +5,7 @@ Linked fragment stage: ...@@ -5,7 +5,7 @@ Linked fragment stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 34 // Id's are bound by 35
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
...@@ -16,9 +16,9 @@ Linked fragment stage: ...@@ -16,9 +16,9 @@ Linked fragment stage:
Name 4 "main" Name 4 "main"
Name 9 "color" Name 9 "color"
Name 11 "BaseColor" Name 11 "BaseColor"
Name 17 "bigColor" Name 18 "bigColor"
Name 27 "d" Name 28 "d"
Name 32 "gl_FragColor" Name 33 "gl_FragColor"
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeFloat 32 6: TypeFloat 32
...@@ -26,16 +26,16 @@ Linked fragment stage: ...@@ -26,16 +26,16 @@ Linked fragment stage:
8: TypePointer Function 7(fvec4) 8: TypePointer Function 7(fvec4)
10: TypePointer Input 7(fvec4) 10: TypePointer Input 7(fvec4)
11(BaseColor): 10(ptr) Variable Input 11(BaseColor): 10(ptr) Variable Input
16: TypePointer UniformConstant 7(fvec4) 17: TypePointer UniformConstant 7(fvec4)
17(bigColor): 16(ptr) Variable UniformConstant 18(bigColor): 17(ptr) Variable UniformConstant
21: TypeInt 32 0 22: TypeInt 32 0
22: 21(int) Constant 0 23: 22(int) Constant 0
23: TypePointer Function 6(float) 24: TypePointer Function 6(float)
26: TypePointer UniformConstant 6(float) 27: TypePointer UniformConstant 6(float)
27(d): 26(ptr) Variable UniformConstant 28(d): 27(ptr) Variable UniformConstant
29: TypeBool 30: TypeBool
31: TypePointer Output 7(fvec4) 32: TypePointer Output 7(fvec4)
32(gl_FragColor): 31(ptr) Variable Output 33(gl_FragColor): 32(ptr) Variable Output
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
9(color): 8(ptr) Variable Function 9(color): 8(ptr) Variable Function
...@@ -43,20 +43,22 @@ Linked fragment stage: ...@@ -43,20 +43,22 @@ Linked fragment stage:
Store 9(color) 12 Store 9(color) 12
Branch 13 Branch 13
13: Label 13: Label
18: 7(fvec4) Load 17(bigColor) LoopMerge 15 16 None
19: 7(fvec4) Load 9(color) Branch 14
20: 7(fvec4) FAdd 19 18
Store 9(color) 20
Branch 15
14: Label 14: Label
33: 7(fvec4) Load 9(color) 19: 7(fvec4) Load 18(bigColor)
Store 32(gl_FragColor) 33 20: 7(fvec4) Load 9(color)
Return 21: 7(fvec4) FAdd 20 19
Store 9(color) 21
Branch 16
15: Label 15: Label
24: 23(ptr) AccessChain 9(color) 22 34: 7(fvec4) Load 9(color)
25: 6(float) Load 24 Store 33(gl_FragColor) 34
28: 6(float) Load 27(d) Return
30: 29(bool) FOrdLessThan 25 28 16: Label
LoopMerge 14 15 None 25: 24(ptr) AccessChain 9(color) 23
BranchConditional 30 13 14 26: 6(float) Load 25
29: 6(float) Load 28(d)
31: 30(bool) FOrdLessThan 26 29
BranchConditional 31 13 15
FunctionEnd FunctionEnd
...@@ -51,30 +51,30 @@ Linked vertex stage: ...@@ -51,30 +51,30 @@ Linked vertex stage:
38(F): 7(ptr) Variable Function 38(F): 7(ptr) Variable Function
42(G): 7(ptr) Variable Function 42(G): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 13 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None
BranchConditional 17 11 12
11: Label
Store 18(A) 19 Store 18(A) 19
20: 6(int) Load 8(i) 20: 6(int) Load 8(i)
22: 6(int) SMod 20 21 22: 6(int) SMod 20 21
23: 16(bool) IEqual 22 9 23: 16(bool) IEqual 22 9
SelectionMerge 25 None SelectionMerge 25 None
BranchConditional 23 24 25 BranchConditional 23 24 25
11: Label 12: Label
Store 42(G) 43 Store 42(G) 43
Return Return
12: Label 13: Label
40: 6(int) Load 8(i) 40: 6(int) Load 8(i)
41: 6(int) IAdd 40 19 41: 6(int) IAdd 40 19
Store 8(i) 41 Store 8(i) 41
Branch 13 Branch 10
13: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 11 12 None
BranchConditional 17 10 11
24: Label 24: Label
Store 26(B) 19 Store 26(B) 19
Branch 12 Branch 13
27: Label 27: Label
Store 28(C) 19 Store 28(C) 19
Branch 25 Branch 25
...@@ -86,11 +86,11 @@ Linked vertex stage: ...@@ -86,11 +86,11 @@ Linked vertex stage:
BranchConditional 32 33 34 BranchConditional 32 33 34
33: Label 33: Label
Store 35(D) 19 Store 35(D) 19
Branch 11 Branch 12
36: Label 36: Label
Store 37(E) 19 Store 37(E) 19
Branch 34 Branch 34
34: Label 34: Label
Store 38(F) 39 Store 38(F) 39
Branch 12 Branch 13
FunctionEnd FunctionEnd
...@@ -39,21 +39,21 @@ Linked vertex stage: ...@@ -39,21 +39,21 @@ Linked vertex stage:
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 13 Branch 10
10: Label 10: Label
Branch 12 14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None
BranchConditional 17 11 12
11: Label 11: Label
Branch 13
12: Label
23: 6(int) Load 8(i) 23: 6(int) Load 8(i)
Store 22(r) 23 Store 22(r) 23
Return Return
12: Label 13: Label
18: 6(int) Load 8(i) 18: 6(int) Load 8(i)
20: 6(int) IAdd 18 19 20: 6(int) IAdd 18 19
Store 8(i) 20 Store 8(i) 20
Branch 13 Branch 10
13: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 11 12 None
BranchConditional 17 10 11
FunctionEnd FunctionEnd
...@@ -7,44 +7,47 @@ Linked vertex stage: ...@@ -7,44 +7,47 @@ Linked vertex stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 22 // Id's are bound by 23
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 14 20 21 EntryPoint Vertex 4 "main" 15 21 22
Source GLSL 450 Source GLSL 450
Name 4 "main" Name 4 "main"
Name 8 "i" Name 8 "i"
Name 14 "r" Name 15 "r"
Name 20 "gl_VertexID" Name 21 "gl_VertexID"
Name 21 "gl_InstanceID" Name 22 "gl_InstanceID"
Decorate 14(r) Location 0 Decorate 15(r) Location 0
Decorate 20(gl_VertexID) BuiltIn VertexId Decorate 21(gl_VertexID) BuiltIn VertexId
Decorate 21(gl_InstanceID) BuiltIn InstanceId Decorate 22(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: 6(int) Constant 0 9: 6(int) Constant 0
13: TypePointer Output 6(int) 14: TypePointer Output 6(int)
14(r): 13(ptr) Variable Output 15(r): 14(ptr) Variable Output
17: 6(int) Constant 1 18: 6(int) Constant 1
19: TypePointer Input 6(int) 20: TypePointer Input 6(int)
20(gl_VertexID): 19(ptr) Variable Input 21(gl_VertexID): 20(ptr) Variable Input
21(gl_InstanceID): 19(ptr) Variable Input 22(gl_InstanceID): 20(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 10 Branch 10
10: Label 10: Label
15: 6(int) Load 8(i) LoopMerge 12 13 None
Store 14(r) 15 Branch 11
Branch 12 11: Label
12: Label
16: 6(int) Load 8(i) 16: 6(int) Load 8(i)
18: 6(int) IAdd 16 17 Store 15(r) 16
Store 8(i) 18 Branch 13
13: Label
17: 6(int) Load 8(i)
19: 6(int) IAdd 17 18
Store 8(i) 19
Branch 10 Branch 10
FunctionEnd FunctionEnd
...@@ -36,20 +36,20 @@ Linked vertex stage: ...@@ -36,20 +36,20 @@ Linked vertex stage:
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
18(j): 7(ptr) Variable Function 18(j): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 13 Branch 10
10: Label 10: Label
Store 18(j) 19 14: 6(int) Load 8(i)
Branch 12 17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None
BranchConditional 17 11 12
11: Label 11: Label
Return Store 18(j) 19
Branch 13
12: Label 12: Label
Return
13: Label
20: 6(int) Load 8(i) 20: 6(int) Load 8(i)
22: 6(int) IAdd 20 21 22: 6(int) IAdd 20 21
Store 8(i) 22 Store 8(i) 22
Branch 13 Branch 10
13: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 11 12 None
BranchConditional 17 10 11
FunctionEnd FunctionEnd
...@@ -75,31 +75,36 @@ Linked fragment stage: ...@@ -75,31 +75,36 @@ Linked fragment stage:
12: 7(fvec4) Load 11(BaseColor) 12: 7(fvec4) Load 11(BaseColor)
Store 9(color) 12 Store 9(color) 12
Store 15(i) 16 Store 15(i) 16
Branch 20 Branch 17
17: Label 17: Label
21: 13(int) Load 15(i)
24: 13(int) Load 23(Count)
26: 25(bool) SLessThan 21 24
LoopMerge 19 20 None
BranchConditional 26 18 19
18: Label
29: 7(fvec4) Load 28(bigColor) 29: 7(fvec4) Load 28(bigColor)
30: 7(fvec4) Load 9(color) 30: 7(fvec4) Load 9(color)
31: 7(fvec4) FAdd 30 29 31: 7(fvec4) FAdd 30 29
Store 9(color) 31 Store 9(color) 31
Branch 19 Branch 20
18: Label 19: Label
37: 7(fvec4) Load 9(color) 37: 7(fvec4) Load 9(color)
Store 36(gl_FragColor) 37 Store 36(gl_FragColor) 37
Store 39(sum) 40 Store 39(sum) 40
Store 41(i) 16 Store 41(i) 16
Branch 45 Branch 42
19: Label 20: Label
32: 13(int) Load 15(i) 32: 13(int) Load 15(i)
34: 13(int) IAdd 32 33 34: 13(int) IAdd 32 33
Store 15(i) 34 Store 15(i) 34
Branch 20 Branch 17
20: Label
21: 13(int) Load 15(i)
24: 13(int) Load 23(Count)
26: 25(bool) SLessThan 21 24
LoopMerge 18 19 None
BranchConditional 26 17 18
42: Label 42: Label
46: 13(int) Load 41(i)
48: 25(bool) SLessThan 46 47
LoopMerge 44 45 None
BranchConditional 48 43 44
43: Label
53: 13(int) Load 41(i) 53: 13(int) Load 41(i)
55: 54(ptr) AccessChain 52(v4) 53 55: 54(ptr) AccessChain 52(v4) 53
56: 49(int) Load 55 56: 49(int) Load 55
...@@ -107,21 +112,21 @@ Linked fragment stage: ...@@ -107,21 +112,21 @@ Linked fragment stage:
58: 6(float) Load 39(sum) 58: 6(float) Load 39(sum)
59: 6(float) FAdd 58 57 59: 6(float) FAdd 58 57
Store 39(sum) 59 Store 39(sum) 59
Branch 44 Branch 45
43: Label
Store 62(i) 16
Branch 66
44: Label 44: Label
Store 62(i) 16
Branch 63
45: Label
60: 13(int) Load 41(i) 60: 13(int) Load 41(i)
61: 13(int) IAdd 60 33 61: 13(int) IAdd 60 33
Store 41(i) 61 Store 41(i) 61
Branch 45 Branch 42
45: Label
46: 13(int) Load 41(i)
48: 25(bool) SLessThan 46 47
LoopMerge 43 44 None
BranchConditional 48 42 43
63: Label 63: Label
67: 13(int) Load 62(i)
68: 25(bool) SLessThan 67 47
LoopMerge 65 66 None
BranchConditional 68 64 65
64: Label
70: 13(int) Load 62(i) 70: 13(int) Load 62(i)
71: 13(int) Load 62(i) 71: 13(int) Load 62(i)
72: 54(ptr) AccessChain 52(v4) 71 72: 54(ptr) AccessChain 52(v4) 71
...@@ -130,8 +135,8 @@ Linked fragment stage: ...@@ -130,8 +135,8 @@ Linked fragment stage:
76: 6(float) ConvertUToF 75 76: 6(float) ConvertUToF 75
77: 38(ptr) AccessChain 69(tv4) 70 77: 38(ptr) AccessChain 69(tv4) 70
Store 77 76 Store 77 76
Branch 65 Branch 66
64: Label 65: Label
80: 6(float) Load 39(sum) 80: 6(float) Load 39(sum)
81: 7(fvec4) CompositeConstruct 80 80 80 80 81: 7(fvec4) CompositeConstruct 80 80 80 80
82: 7(fvec4) Load 69(tv4) 82: 7(fvec4) Load 69(tv4)
...@@ -145,23 +150,24 @@ Linked fragment stage: ...@@ -145,23 +150,24 @@ Linked fragment stage:
91: 7(fvec4) VectorShuffle 90 89 4 5 6 3 91: 7(fvec4) VectorShuffle 90 89 4 5 6 3
Store 86(r) 91 Store 86(r) 91
Store 92(i) 16 Store 92(i) 16
Branch 96 Branch 93
65: Label 66: Label
78: 13(int) Load 62(i) 78: 13(int) Load 62(i)
79: 13(int) IAdd 78 33 79: 13(int) IAdd 78 33
Store 62(i) 79 Store 62(i) 79
Branch 66 Branch 63
66: Label
67: 13(int) Load 62(i)
68: 25(bool) SLessThan 67 47
LoopMerge 64 65 None
BranchConditional 68 63 64
93: Label 93: Label
97: 13(int) Load 92(i)
98: 13(int) Load 23(Count)
99: 25(bool) SLessThan 97 98
LoopMerge 95 96 None
BranchConditional 99 94 95
94: Label
102: 6(float) Load 101(f) 102: 6(float) Load 101(f)
104: 38(ptr) AccessChain 86(r) 103 104: 38(ptr) AccessChain 86(r) 103
Store 104 102 Store 104 102
Branch 95 Branch 96
94: Label 95: Label
107: 7(fvec4) Load 86(r) 107: 7(fvec4) Load 86(r)
108: 87(fvec3) VectorShuffle 107 107 0 1 2 108: 87(fvec3) VectorShuffle 107 107 0 1 2
109: 7(fvec4) Load 36(gl_FragColor) 109: 7(fvec4) Load 36(gl_FragColor)
...@@ -171,34 +177,28 @@ Linked fragment stage: ...@@ -171,34 +177,28 @@ Linked fragment stage:
113: 7(fvec4) VectorShuffle 112 111 4 5 6 3 113: 7(fvec4) VectorShuffle 112 111 4 5 6 3
Store 36(gl_FragColor) 113 Store 36(gl_FragColor) 113
Store 114(i) 16 Store 114(i) 16
Branch 118 Branch 115
95: Label 96: Label
105: 13(int) Load 92(i) 105: 13(int) Load 92(i)
106: 13(int) IAdd 105 33 106: 13(int) IAdd 105 33
Store 92(i) 106 Store 92(i) 106
Branch 96 Branch 93
96: Label
97: 13(int) Load 92(i)
98: 13(int) Load 23(Count)
99: 25(bool) SLessThan 97 98
LoopMerge 94 95 None
BranchConditional 99 93 94
115: Label 115: Label
119: 13(int) Load 114(i)
121: 25(bool) SLessThan 119 120
LoopMerge 117 118 None
BranchConditional 121 116 117
116: Label
122: 6(float) Load 101(f) 122: 6(float) Load 101(f)
123: 7(fvec4) Load 36(gl_FragColor) 123: 7(fvec4) Load 36(gl_FragColor)
124: 7(fvec4) VectorTimesScalar 123 122 124: 7(fvec4) VectorTimesScalar 123 122
Store 36(gl_FragColor) 124 Store 36(gl_FragColor) 124
Branch 117 Branch 118
116: Label
Return
117: Label 117: Label
Return
118: Label
125: 13(int) Load 114(i) 125: 13(int) Load 114(i)
126: 13(int) IAdd 125 47 126: 13(int) IAdd 125 47
Store 114(i) 126 Store 114(i) 126
Branch 118 Branch 115
118: Label
119: 13(int) Load 114(i)
121: 25(bool) SLessThan 119 120
LoopMerge 116 117 None
BranchConditional 121 115 116
FunctionEnd FunctionEnd
...@@ -159,27 +159,27 @@ Linked fragment stage: ...@@ -159,27 +159,27 @@ Linked fragment stage:
74: 30(ptr) AccessChain 70(localArray) 71 74: 30(ptr) AccessChain 70(localArray) 71
Store 74 73 Store 74 73
Store 75(i) 16 Store 75(i) 16
Branch 79 Branch 76
76: Label 76: Label
80: 6(int) Load 75(i)
82: 23(bool) SLessThan 80 81
LoopMerge 78 79 None
BranchConditional 82 77 78
77: Label
84: 6(int) Load 75(i) 84: 6(int) Load 75(i)
86: 30(ptr) AccessChain 83(a) 84 86: 30(ptr) AccessChain 83(a) 84
Store 86 85 Store 86 85
Branch 78 Branch 79
77: Label 78: Label
90: 6(int) Load 89(condition) 90: 6(int) Load 89(condition)
91: 23(bool) IEqual 90 28 91: 23(bool) IEqual 90 28
SelectionMerge 93 None SelectionMerge 93 None
BranchConditional 91 92 93 BranchConditional 91 92 93
78: Label 79: Label
87: 6(int) Load 75(i) 87: 6(int) Load 75(i)
88: 6(int) IAdd 87 28 88: 6(int) IAdd 87 28
Store 75(i) 88 Store 75(i) 88
Branch 79 Branch 76
79: Label
80: 6(int) Load 75(i)
82: 23(bool) SLessThan 80 81
LoopMerge 77 78 None
BranchConditional 82 76 77
92: Label 92: Label
94: 34 Load 70(localArray) 94: 34 Load 70(localArray)
Store 83(a) 94 Store 83(a) 94
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -216,29 +216,29 @@ Linked fragment stage: ...@@ -216,29 +216,29 @@ Linked fragment stage:
Branch 121 Branch 121
121: Label 121: Label
Store 153(i) 154 Store 153(i) 154
Branch 158 Branch 155
155: Label 155: Label
159: 9(int) Load 153(i)
162: 161(bool) SLessThan 159 160
LoopMerge 157 158 None
BranchConditional 162 156 157
156: Label
163: 9(int) Load 60(c) 163: 9(int) Load 60(c)
SelectionMerge 167 None SelectionMerge 167 None
Switch 163 166 Switch 163 166
case 1: 164 case 1: 164
case 2: 165 case 2: 165
156: Label 157: Label
211: 9(int) Load 60(c) 211: 9(int) Load 60(c)
SelectionMerge 214 None SelectionMerge 214 None
Switch 211 214 Switch 211 214
case 1: 212 case 1: 212
case 2: 213 case 2: 213
157: Label 158: Label
209: 9(int) Load 153(i) 209: 9(int) Load 153(i)
210: 9(int) IAdd 209 63 210: 9(int) IAdd 209 63
Store 153(i) 210 Store 153(i) 210
Branch 158 Branch 155
158: Label
159: 9(int) Load 153(i)
162: 161(bool) SLessThan 159 160
LoopMerge 156 157 None
BranchConditional 162 155 156
164: Label 164: Label
168: 6(float) Load 73(x) 168: 6(float) Load 73(x)
169: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 168 169: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 168
...@@ -246,8 +246,13 @@ Linked fragment stage: ...@@ -246,8 +246,13 @@ Linked fragment stage:
171: 6(float) FAdd 170 169 171: 6(float) FAdd 170 169
Store 71(f) 171 Store 71(f) 171
Store 172(j) 173 Store 172(j) 173
Branch 177 Branch 174
174: Label 174: Label
178: 9(int) Load 172(j)
180: 161(bool) SLessThan 178 179
LoopMerge 176 177 None
BranchConditional 180 175 176
175: Label
181: 6(float) Load 71(f) 181: 6(float) Load 71(f)
182: 6(float) FAdd 181 47 182: 6(float) FAdd 181 47
Store 71(f) 182 Store 71(f) 182
...@@ -255,22 +260,17 @@ Linked fragment stage: ...@@ -255,22 +260,17 @@ Linked fragment stage:
185: 161(bool) FOrdLessThan 183 184 185: 161(bool) FOrdLessThan 183 184
SelectionMerge 187 None SelectionMerge 187 None
BranchConditional 185 186 187 BranchConditional 185 186 187
175: Label
Branch 167
176: Label 176: Label
Branch 167
177: Label
189: 9(int) Load 172(j) 189: 9(int) Load 172(j)
190: 9(int) IAdd 189 63 190: 9(int) IAdd 189 63
Store 172(j) 190 Store 172(j) 190
Branch 177 Branch 174
177: Label
178: 9(int) Load 172(j)
180: 161(bool) SLessThan 178 179
LoopMerge 175 176 None
BranchConditional 180 174 175
186: Label 186: Label
Branch 175
187: Label
Branch 176 Branch 176
187: Label
Branch 177
165: Label 165: Label
192: 6(float) Load 73(x) 192: 6(float) Load 73(x)
193: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 192 193: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 192
...@@ -291,9 +291,9 @@ Linked fragment stage: ...@@ -291,9 +291,9 @@ Linked fragment stage:
SelectionMerge 207 None SelectionMerge 207 None
BranchConditional 205 206 207 BranchConditional 205 206 207
206: Label 206: Label
Branch 156
207: Label
Branch 157 Branch 157
207: Label
Branch 158
212: Label 212: Label
215: 6(float) Load 73(x) 215: 6(float) Load 73(x)
216: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 215 216: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 215
......
...@@ -44,27 +44,27 @@ Linked vertex stage: ...@@ -44,27 +44,27 @@ Linked vertex stage:
28(C): 7(ptr) Variable Function 28(C): 7(ptr) Variable Function
38(D): 7(ptr) Variable Function 38(D): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 13 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None
BranchConditional 17 11 12
11: Label
Store 18(A) 19 Store 18(A) 19
20: 6(int) Load 8(i) 20: 6(int) Load 8(i)
22: 6(int) SMod 20 21 22: 6(int) SMod 20 21
23: 16(bool) IEqual 22 9 23: 16(bool) IEqual 22 9
SelectionMerge 25 None SelectionMerge 25 None
BranchConditional 23 24 25 BranchConditional 23 24 25
11: Label 12: Label
Store 38(D) 39 Store 38(D) 39
Return Return
12: Label
Branch 13
13: Label 13: Label
14: 6(int) Load 8(i) Branch 10
17: 16(bool) SLessThan 14 15
LoopMerge 11 12 None
BranchConditional 17 10 11
24: Label 24: Label
Store 26(B) 21 Store 26(B) 21
Branch 12 Branch 13
27: Label 27: Label
Store 28(C) 21 Store 28(C) 21
Branch 25 Branch 25
...@@ -76,7 +76,7 @@ Linked vertex stage: ...@@ -76,7 +76,7 @@ Linked vertex stage:
BranchConditional 32 33 34 BranchConditional 32 33 34
33: Label 33: Label
Store 26(B) 21 Store 26(B) 21
Branch 11 Branch 12
35: Label 35: Label
Store 28(C) 21 Store 28(C) 21
Branch 34 Branch 34
...@@ -84,5 +84,5 @@ Linked vertex stage: ...@@ -84,5 +84,5 @@ Linked vertex stage:
36: 6(int) Load 8(i) 36: 6(int) Load 8(i)
37: 6(int) IAdd 36 19 37: 6(int) IAdd 36 19
Store 8(i) 37 Store 8(i) 37
Branch 12 Branch 13
FunctionEnd FunctionEnd
...@@ -33,19 +33,19 @@ Linked vertex stage: ...@@ -33,19 +33,19 @@ Linked vertex stage:
5: Label 5: Label
8(i): 7(ptr) Variable Function 8(i): 7(ptr) Variable Function
Store 8(i) 9 Store 8(i) 9
Branch 13 Branch 10
10: Label 10: Label
14: 6(int) Load 8(i)
17: 16(bool) SLessThan 14 15
LoopMerge 12 13 None
BranchConditional 17 11 12
11: Label
18: 6(int) Load 8(i) 18: 6(int) Load 8(i)
20: 6(int) IAdd 18 19 20: 6(int) IAdd 18 19
Store 8(i) 20 Store 8(i) 20
Branch 12
11: Label
Return
12: Label
Branch 13 Branch 13
12: Label
Return
13: Label 13: Label
14: 6(int) Load 8(i) Branch 10
17: 16(bool) SLessThan 14 15
LoopMerge 11 12 None
BranchConditional 17 10 11
FunctionEnd FunctionEnd
...@@ -41,24 +41,24 @@ Linked fragment stage: ...@@ -41,24 +41,24 @@ Linked fragment stage:
9(color): 8(ptr) Variable Function 9(color): 8(ptr) Variable Function
12: 7(fvec4) Load 11(BaseColor) 12: 7(fvec4) Load 11(BaseColor)
Store 9(color) 12 Store 9(color) 12
Branch 16 Branch 13
13: Label 13: Label
20: 19(ptr) AccessChain 9(color) 18
21: 6(float) Load 20
24: 6(float) Load 23(d)
26: 25(bool) FOrdLessThan 21 24
LoopMerge 15 16 None
BranchConditional 26 14 15
14: Label
29: 7(fvec4) Load 28(bigColor) 29: 7(fvec4) Load 28(bigColor)
30: 7(fvec4) Load 9(color) 30: 7(fvec4) Load 9(color)
31: 7(fvec4) FAdd 30 29 31: 7(fvec4) FAdd 30 29
Store 9(color) 31 Store 9(color) 31
Branch 15 Branch 16
14: Label 15: Label
34: 7(fvec4) Load 9(color) 34: 7(fvec4) Load 9(color)
Store 33(gl_FragColor) 34 Store 33(gl_FragColor) 34
Return Return
15: Label
Branch 16
16: Label 16: Label
20: 19(ptr) AccessChain 9(color) 18 Branch 13
21: 6(float) Load 20
24: 6(float) Load 23(d)
26: 25(bool) FOrdLessThan 21 24
LoopMerge 14 15 None
BranchConditional 26 13 14
FunctionEnd FunctionEnd
...@@ -2,5 +2,8 @@ ...@@ -2,5 +2,8 @@
layout(location=0) out highp int r; layout(location=0) out highp int r;
void main() { void main() {
int i; int i;
// This infinite loop results in bad SPIR-V generated, since the merge block
// is dropped as unreachable. It is still useful for testing the rest of the
// code generation.
for (i=0; ; i++) { r = i; } for (i=0; ; i++) { r = i; }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment