HLSL: Fix #1249: Always execute both sides of ternary "?:".

This is semantically required by HLSL, and frequently results in using
OpSelect instead of control flow.
This commit is contained in:
John Kessenich
2018-02-20 21:29:05 -07:00
parent a5cae08259
commit 4bee531fc1
17 changed files with 776 additions and 850 deletions

View File

@@ -86,7 +86,7 @@ gl_FragCoord origin is upper left
0:25 'uint' ( temp mediump uint)
0:25 'min16float' ( temp mediump float)
0:25 'min10float' ( temp mediump float)
0:25 Test condition and select ( temp mediump float)
0:25 Test condition and select ( temp mediump float): no shortcircuit
0:25 Condition
0:25 direct index ( temp bool)
0:25 'bool' ( temp 2-element array of bool)
@@ -221,7 +221,7 @@ gl_FragCoord origin is upper left
0:25 'uint' ( temp mediump uint)
0:25 'min16float' ( temp mediump float)
0:25 'min10float' ( temp mediump float)
0:25 Test condition and select ( temp mediump float)
0:25 Test condition and select ( temp mediump float): no shortcircuit
0:25 Condition
0:25 direct index ( temp bool)
0:25 'bool' ( temp 2-element array of bool)
@@ -267,12 +267,12 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Generated by (magic number): 80004
// Id's are bound by 109
// Id's are bound by 105
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 107
EntryPoint Fragment 4 "main" 103
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
@@ -289,9 +289,9 @@ gl_FragCoord origin is upper left
Name 56 "foo_t"
MemberName 56(foo_t) 0 "float"
Name 58 "float"
Name 86 "param"
Name 93 "half2x3"
Name 107 "@entryPointOutput"
Name 82 "param"
Name 89 "half2x3"
Name 103 "@entryPointOutput"
Decorate 49(min16float) RelaxedPrecision
Decorate 50 RelaxedPrecision
Decorate 51 RelaxedPrecision
@@ -308,15 +308,14 @@ gl_FragCoord origin is upper left
Decorate 72 RelaxedPrecision
Decorate 73 RelaxedPrecision
Decorate 74 RelaxedPrecision
Decorate 80 RelaxedPrecision
Decorate 77 RelaxedPrecision
Decorate 78 RelaxedPrecision
Decorate 79 RelaxedPrecision
Decorate 81 RelaxedPrecision
Decorate 83 RelaxedPrecision
Decorate 84 RelaxedPrecision
Decorate 85 RelaxedPrecision
Decorate 87 RelaxedPrecision
Decorate 88 RelaxedPrecision
Decorate 89 RelaxedPrecision
Decorate 107(@entryPointOutput) Location 0
Decorate 103(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -341,16 +340,16 @@ gl_FragCoord origin is upper left
56(foo_t): TypeStruct 6(float)
57: TypePointer Function 56(foo_t)
59: 6(float) Constant 1109917696
90: TypeVector 6(float) 3
91: TypeMatrix 90(fvec3) 2
92: TypePointer Function 91
97: 22(int) Constant 0
106: TypePointer Output 12(fvec4)
107(@entryPointOutput): 106(ptr) Variable Output
86: TypeVector 6(float) 3
87: TypeMatrix 86(fvec3) 2
88: TypePointer Function 87
93: 22(int) Constant 0
102: TypePointer Output 12(fvec4)
103(@entryPointOutput): 102(ptr) Variable Output
4(main): 2 Function None 3
5: Label
108: 12(fvec4) FunctionCall 14(@main()
Store 107(@entryPointOutput) 108
104: 12(fvec4) FunctionCall 14(@main()
Store 103(@entryPointOutput) 104
Return
FunctionEnd
10(fn(f1;): 6(float) Function None 8
@@ -369,9 +368,8 @@ gl_FragCoord origin is upper left
52(min10float): 7(ptr) Variable Function
54(half): 7(ptr) Variable Function
58(float): 57(ptr) Variable Function
75: 7(ptr) Variable Function
86(param): 7(ptr) Variable Function
93(half2x3): 92(ptr) Variable Function
82(param): 7(ptr) Variable Function
89(half2x3): 88(ptr) Variable Function
Store 19(float) 20
27: 6(float) Load 19(float)
29: 21(bool) FOrdNotEqual 27 28
@@ -412,36 +410,27 @@ gl_FragCoord origin is upper left
72: 6(float) FAdd 70 71
73: 6(float) Load 52(min10float)
74: 6(float) FAdd 72 73
76: 37(ptr) AccessChain 26(bool) 40
77: 21(bool) Load 76
SelectionMerge 79 None
BranchConditional 77 78 82
78: Label
80: 33(int) Load 35(int)
81: 6(float) ConvertSToF 80
Store 75 81
Branch 79
82: Label
83: 6(float) Load 19(float)
Store 75 83
Branch 79
79: Label
84: 6(float) Load 75
85: 6(float) FAdd 74 84
87: 6(float) Load 19(float)
Store 86(param) 87
88: 6(float) FunctionCall 10(fn(f1;) 86(param)
89: 6(float) FAdd 85 88
Store 19(float) 89
94: 6(float) Load 19(float)
75: 37(ptr) AccessChain 26(bool) 40
76: 21(bool) Load 75
77: 33(int) Load 35(int)
78: 6(float) ConvertSToF 77
79: 6(float) Load 19(float)
80: 6(float) Select 76 78 79
81: 6(float) FAdd 74 80
83: 6(float) Load 19(float)
Store 82(param) 83
84: 6(float) FunctionCall 10(fn(f1;) 82(param)
85: 6(float) FAdd 81 84
Store 19(float) 85
90: 6(float) Load 19(float)
91: 6(float) Load 19(float)
92: 6(float) FMul 90 91
94: 7(ptr) AccessChain 89(half2x3) 40 93
Store 94 92
95: 6(float) Load 19(float)
96: 6(float) FMul 94 95
98: 7(ptr) AccessChain 93(half2x3) 40 97
Store 98 96
99: 6(float) Load 19(float)
100: 7(ptr) AccessChain 93(half2x3) 40 97
101: 6(float) Load 100
102: 6(float) FAdd 99 101
103: 12(fvec4) CompositeConstruct 102 102 102 102
ReturnValue 103
96: 7(ptr) AccessChain 89(half2x3) 40 93
97: 6(float) Load 96
98: 6(float) FAdd 95 97
99: 12(fvec4) CompositeConstruct 98 98 98 98
ReturnValue 99
FunctionEnd