SPIR-V: Aggressively prune unreachable merge, continue target
More aggressively prune unreachable code as follows.
When no control flow edges reach a merge block or continue target:
- delete their contents so that:
- a merge block becomes OpLabel, then OpUnreachable
- a continue target becomes OpLabel, then an OpBranch back to the
loop header
- any basic block which is dominated by such a merge block or continue
target is removed as well.
- decorations targeting the removed instructions are removed.
Enables the SPIR-V builder post-processing step the GLSLANG_WEB case.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
spv.controlFlowAttributes.frag
|
||||
WARNING: 0:20: 'unroll' : expected no arguments
|
||||
WARNING: 0:21: 'dont_unroll' : expected no arguments
|
||||
WARNING: 0:22: 'dependency_infinite' : expected no arguments
|
||||
WARNING: 0:23: 'dependency_length' : expected a single integer argument
|
||||
WARNING: 0:24: '' : attribute with arguments not recognized, skipping
|
||||
WARNING: 0:25: '' : attribute with arguments not recognized, skipping
|
||||
WARNING: 0:26: '' : attribute with arguments not recognized, skipping
|
||||
WARNING: 0:27: 'unroll' : expected no arguments
|
||||
WARNING: 0:28: 'dont_unroll' : expected no arguments
|
||||
WARNING: 0:29: 'dependency_infinite' : expected no arguments
|
||||
WARNING: 0:30: 'dependency_length' : expected a single integer argument
|
||||
WARNING: 0:31: '' : attribute with arguments not recognized, skipping
|
||||
WARNING: 0:32: '' : attribute with arguments not recognized, skipping
|
||||
WARNING: 0:33: '' : attribute with arguments not recognized, skipping
|
||||
|
||||
Validation failed
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80007
|
||||
// Id's are bound by 118
|
||||
// Id's are bound by 123
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
@@ -20,220 +20,231 @@ Validation failed
|
||||
Source GLSL 450
|
||||
SourceExtension "GL_EXT_control_flow_attributes"
|
||||
Name 4 "main"
|
||||
Name 8 "i"
|
||||
Name 36 "i"
|
||||
Name 47 "cond"
|
||||
Name 60 "i"
|
||||
Name 79 "i"
|
||||
Name 6 "f0("
|
||||
Name 8 "f1("
|
||||
Name 23 "i"
|
||||
Name 41 "i"
|
||||
Name 52 "cond"
|
||||
Name 65 "i"
|
||||
Name 84 "i"
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 32 1
|
||||
7: TypePointer Function 6(int)
|
||||
9: 6(int) Constant 0
|
||||
16: 6(int) Constant 8
|
||||
17: TypeBool
|
||||
20: 6(int) Constant 1
|
||||
31: 17(bool) ConstantTrue
|
||||
46: TypePointer Private 17(bool)
|
||||
47(cond): 46(ptr) Variable Private
|
||||
54: 17(bool) ConstantFalse
|
||||
55: 6(int) Constant 3
|
||||
19: TypeBool
|
||||
20: 19(bool) ConstantTrue
|
||||
21: TypeInt 32 1
|
||||
22: TypePointer Function 21(int)
|
||||
24: 21(int) Constant 0
|
||||
31: 21(int) Constant 8
|
||||
34: 21(int) Constant 1
|
||||
51: TypePointer Private 19(bool)
|
||||
52(cond): 51(ptr) Variable Private
|
||||
59: 19(bool) ConstantFalse
|
||||
60: 21(int) Constant 3
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
8(i): 7(ptr) Variable Function
|
||||
36(i): 7(ptr) Variable Function
|
||||
60(i): 7(ptr) Variable Function
|
||||
79(i): 7(ptr) Variable Function
|
||||
Store 8(i) 9
|
||||
Branch 10
|
||||
10: Label
|
||||
LoopMerge 12 13 Unroll
|
||||
Branch 14
|
||||
14: Label
|
||||
15: 6(int) Load 8(i)
|
||||
18: 17(bool) SLessThan 15 16
|
||||
BranchConditional 18 11 12
|
||||
11: Label
|
||||
Branch 13
|
||||
13: Label
|
||||
19: 6(int) Load 8(i)
|
||||
21: 6(int) IAdd 19 20
|
||||
Store 8(i) 21
|
||||
Branch 10
|
||||
12: Label
|
||||
Branch 22
|
||||
22: Label
|
||||
LoopMerge 24 25 DontUnroll
|
||||
Branch 23
|
||||
23: Label
|
||||
23(i): 22(ptr) Variable Function
|
||||
41(i): 22(ptr) Variable Function
|
||||
65(i): 22(ptr) Variable Function
|
||||
84(i): 22(ptr) Variable Function
|
||||
Store 23(i) 24
|
||||
Branch 25
|
||||
25: Label
|
||||
Branch 22
|
||||
24: Label
|
||||
Branch 26
|
||||
26: Label
|
||||
LoopMerge 28 29 DontUnroll
|
||||
Branch 30
|
||||
30: Label
|
||||
BranchConditional 31 27 28
|
||||
27: Label
|
||||
Branch 29
|
||||
29: Label
|
||||
Branch 26
|
||||
28: Label
|
||||
Branch 32
|
||||
32: Label
|
||||
LoopMerge 34 35 DependencyInfinite
|
||||
Branch 33
|
||||
33: Label
|
||||
Branch 35
|
||||
35: Label
|
||||
BranchConditional 31 32 34
|
||||
34: Label
|
||||
Store 36(i) 9
|
||||
LoopMerge 27 28 Unroll
|
||||
Branch 29
|
||||
29: Label
|
||||
30: 21(int) Load 23(i)
|
||||
32: 19(bool) SLessThan 30 31
|
||||
BranchConditional 32 26 27
|
||||
26: Label
|
||||
Branch 28
|
||||
28: Label
|
||||
33: 21(int) Load 23(i)
|
||||
35: 21(int) IAdd 33 34
|
||||
Store 23(i) 35
|
||||
Branch 25
|
||||
27: Label
|
||||
36: 2 FunctionCall 6(f0()
|
||||
Branch 37
|
||||
37: Label
|
||||
LoopMerge 39 40 DependencyLength 4
|
||||
Branch 41
|
||||
41: Label
|
||||
42: 6(int) Load 36(i)
|
||||
43: 17(bool) SLessThan 42 16
|
||||
BranchConditional 43 38 39
|
||||
38: Label
|
||||
Branch 40
|
||||
40: Label
|
||||
44: 6(int) Load 36(i)
|
||||
45: 6(int) IAdd 44 20
|
||||
Store 36(i) 45
|
||||
Branch 37
|
||||
LoopMerge 39 40 DependencyInfinite
|
||||
Branch 38
|
||||
38: Label
|
||||
Branch 40
|
||||
40: Label
|
||||
BranchConditional 20 37 39
|
||||
39: Label
|
||||
48: 17(bool) Load 47(cond)
|
||||
SelectionMerge 50 Flatten
|
||||
BranchConditional 48 49 50
|
||||
49: Label
|
||||
Branch 50
|
||||
50: Label
|
||||
51: 17(bool) Load 47(cond)
|
||||
SelectionMerge 53 DontFlatten
|
||||
BranchConditional 51 52 53
|
||||
52: Label
|
||||
Store 47(cond) 54
|
||||
Branch 53
|
||||
53: Label
|
||||
SelectionMerge 57 DontFlatten
|
||||
Switch 55 57
|
||||
case 3: 56
|
||||
56: Label
|
||||
Branch 57
|
||||
57: Label
|
||||
Store 60(i) 9
|
||||
Branch 61
|
||||
61: Label
|
||||
LoopMerge 63 64 None
|
||||
Branch 65
|
||||
65: Label
|
||||
66: 6(int) Load 60(i)
|
||||
67: 17(bool) SLessThan 66 16
|
||||
BranchConditional 67 62 63
|
||||
62: Label
|
||||
Branch 64
|
||||
64: Label
|
||||
68: 6(int) Load 60(i)
|
||||
69: 6(int) IAdd 68 20
|
||||
Store 60(i) 69
|
||||
Branch 61
|
||||
63: Label
|
||||
Store 41(i) 24
|
||||
Branch 42
|
||||
42: Label
|
||||
LoopMerge 44 45 DependencyLength 4
|
||||
Branch 46
|
||||
46: Label
|
||||
47: 21(int) Load 41(i)
|
||||
48: 19(bool) SLessThan 47 31
|
||||
BranchConditional 48 43 44
|
||||
43: Label
|
||||
Branch 45
|
||||
45: Label
|
||||
49: 21(int) Load 41(i)
|
||||
50: 21(int) IAdd 49 34
|
||||
Store 41(i) 50
|
||||
Branch 42
|
||||
44: Label
|
||||
53: 19(bool) Load 52(cond)
|
||||
SelectionMerge 55 Flatten
|
||||
BranchConditional 53 54 55
|
||||
54: Label
|
||||
Branch 55
|
||||
55: Label
|
||||
56: 19(bool) Load 52(cond)
|
||||
SelectionMerge 58 DontFlatten
|
||||
BranchConditional 56 57 58
|
||||
57: Label
|
||||
Store 52(cond) 59
|
||||
Branch 58
|
||||
58: Label
|
||||
SelectionMerge 62 DontFlatten
|
||||
Switch 60 62
|
||||
case 3: 61
|
||||
61: Label
|
||||
Branch 62
|
||||
62: Label
|
||||
Store 65(i) 24
|
||||
Branch 66
|
||||
66: Label
|
||||
LoopMerge 68 69 None
|
||||
Branch 70
|
||||
70: Label
|
||||
LoopMerge 72 73 None
|
||||
Branch 74
|
||||
74: Label
|
||||
BranchConditional 31 71 72
|
||||
71: Label
|
||||
Branch 73
|
||||
73: Label
|
||||
Branch 70
|
||||
72: Label
|
||||
71: 21(int) Load 65(i)
|
||||
72: 19(bool) SLessThan 71 31
|
||||
BranchConditional 72 67 68
|
||||
67: Label
|
||||
Branch 69
|
||||
69: Label
|
||||
73: 21(int) Load 65(i)
|
||||
74: 21(int) IAdd 73 34
|
||||
Store 65(i) 74
|
||||
Branch 66
|
||||
68: Label
|
||||
Branch 75
|
||||
75: Label
|
||||
LoopMerge 77 78 None
|
||||
Branch 76
|
||||
76: Label
|
||||
Branch 78
|
||||
78: Label
|
||||
BranchConditional 31 75 77
|
||||
Branch 79
|
||||
79: Label
|
||||
BranchConditional 20 76 77
|
||||
76: Label
|
||||
Branch 78
|
||||
78: Label
|
||||
Branch 75
|
||||
77: Label
|
||||
Store 79(i) 9
|
||||
Branch 80
|
||||
80: Label
|
||||
LoopMerge 82 83 None
|
||||
Branch 84
|
||||
84: Label
|
||||
85: 6(int) Load 79(i)
|
||||
86: 17(bool) SLessThan 85 16
|
||||
BranchConditional 86 81 82
|
||||
81: Label
|
||||
Branch 83
|
||||
83: Label
|
||||
87: 6(int) Load 79(i)
|
||||
88: 6(int) IAdd 87 20
|
||||
Store 79(i) 88
|
||||
Branch 80
|
||||
Branch 81
|
||||
81: Label
|
||||
Branch 83
|
||||
83: Label
|
||||
BranchConditional 20 80 82
|
||||
82: Label
|
||||
89: 17(bool) Load 47(cond)
|
||||
SelectionMerge 91 None
|
||||
BranchConditional 89 90 91
|
||||
90: Label
|
||||
Branch 91
|
||||
91: Label
|
||||
92: 17(bool) Load 47(cond)
|
||||
SelectionMerge 94 None
|
||||
BranchConditional 92 93 94
|
||||
93: Label
|
||||
Store 47(cond) 54
|
||||
Branch 94
|
||||
94: Label
|
||||
Store 84(i) 24
|
||||
Branch 85
|
||||
85: Label
|
||||
LoopMerge 87 88 None
|
||||
Branch 89
|
||||
89: Label
|
||||
90: 21(int) Load 84(i)
|
||||
91: 19(bool) SLessThan 90 31
|
||||
BranchConditional 91 86 87
|
||||
86: Label
|
||||
Branch 88
|
||||
88: Label
|
||||
92: 21(int) Load 84(i)
|
||||
93: 21(int) IAdd 92 34
|
||||
Store 84(i) 93
|
||||
Branch 85
|
||||
87: Label
|
||||
94: 19(bool) Load 52(cond)
|
||||
SelectionMerge 96 None
|
||||
Switch 55 96
|
||||
case 3: 95
|
||||
BranchConditional 94 95 96
|
||||
95: Label
|
||||
Branch 96
|
||||
96: Label
|
||||
Branch 99
|
||||
99: Label
|
||||
LoopMerge 101 102 Unroll DontUnroll DependencyLength 2
|
||||
Branch 103
|
||||
103: Label
|
||||
104: 17(bool) Load 47(cond)
|
||||
BranchConditional 104 100 101
|
||||
100: Label
|
||||
Branch 102
|
||||
102: Label
|
||||
97: 19(bool) Load 52(cond)
|
||||
SelectionMerge 99 None
|
||||
BranchConditional 97 98 99
|
||||
98: Label
|
||||
Store 52(cond) 59
|
||||
Branch 99
|
||||
99: Label
|
||||
SelectionMerge 101 None
|
||||
Switch 60 101
|
||||
case 3: 100
|
||||
100: Label
|
||||
Branch 101
|
||||
101: Label
|
||||
SelectionMerge 106 DontFlatten
|
||||
Switch 55 106
|
||||
case 3: 105
|
||||
Branch 104
|
||||
104: Label
|
||||
LoopMerge 106 107 Unroll DontUnroll DependencyLength 2
|
||||
Branch 108
|
||||
108: Label
|
||||
109: 19(bool) Load 52(cond)
|
||||
BranchConditional 109 105 106
|
||||
105: Label
|
||||
Branch 106
|
||||
Branch 107
|
||||
107: Label
|
||||
Branch 104
|
||||
106: Label
|
||||
109: 17(bool) Load 47(cond)
|
||||
SelectionMerge 111 Flatten
|
||||
BranchConditional 109 110 111
|
||||
SelectionMerge 111 DontFlatten
|
||||
Switch 60 111
|
||||
case 3: 110
|
||||
110: Label
|
||||
Branch 111
|
||||
111: Label
|
||||
Branch 112
|
||||
112: Label
|
||||
LoopMerge 114 115 DependencyInfinite
|
||||
Branch 116
|
||||
116: Label
|
||||
117: 17(bool) Load 47(cond)
|
||||
BranchConditional 117 113 114
|
||||
113: Label
|
||||
Branch 115
|
||||
114: 19(bool) Load 52(cond)
|
||||
SelectionMerge 116 Flatten
|
||||
BranchConditional 114 115 116
|
||||
115: Label
|
||||
Branch 112
|
||||
114: Label
|
||||
Branch 116
|
||||
116: Label
|
||||
Branch 117
|
||||
117: Label
|
||||
LoopMerge 119 120 DependencyInfinite
|
||||
Branch 121
|
||||
121: Label
|
||||
122: 19(bool) Load 52(cond)
|
||||
BranchConditional 122 118 119
|
||||
118: Label
|
||||
Branch 120
|
||||
120: Label
|
||||
Branch 117
|
||||
119: Label
|
||||
Return
|
||||
FunctionEnd
|
||||
6(f0(): 2 Function None 3
|
||||
7: Label
|
||||
Branch 10
|
||||
10: Label
|
||||
LoopMerge 12 13 DontUnroll
|
||||
Branch 11
|
||||
11: Label
|
||||
Branch 13
|
||||
13: Label
|
||||
Branch 10
|
||||
12: Label
|
||||
Unreachable
|
||||
FunctionEnd
|
||||
8(f1(): 2 Function None 3
|
||||
9: Label
|
||||
Branch 14
|
||||
14: Label
|
||||
LoopMerge 16 17 DontUnroll
|
||||
Branch 18
|
||||
18: Label
|
||||
BranchConditional 20 15 16
|
||||
15: Label
|
||||
Branch 17
|
||||
17: Label
|
||||
Branch 14
|
||||
16: Label
|
||||
Return
|
||||
FunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user