HLSL: Fix #884: Use promoted children, not pre-promoted, in completing binary nodes.
authorJohn Kessenich <cepheus@frii.com>
Fri, 12 May 2017 21:25:41 +0000 (15:25 -0600)
committerJohn Kessenich <cepheus@frii.com>
Fri, 12 May 2017 21:25:41 +0000 (15:25 -0600)
Test/baseResults/hlsl.logicalConvert.frag.out
Test/hlsl.logicalConvert.frag
glslang/MachineIndependent/Intermediate.cpp

index a49a7185f37821026299c8901a0f57ffa1559d64..b51a43ca6cec5dc6e8f83c7921e1b6e112733d76 100755 (executable)
@@ -71,6 +71,50 @@ gl_FragCoord origin is upper left
 0:14            0.000000
 0:14            0.000000
 0:14            0.000000
+0:15      Test condition and select ( temp void)
+0:15        Condition
+0:15        Constant:
+0:15          true (const bool)
+0:15        true case
+0:16        Branch: Return with expression
+0:16          Constant:
+0:16            0.000000
+0:16            0.000000
+0:16            0.000000
+0:16            0.000000
+0:17      Test condition and select ( temp void)
+0:17        Condition
+0:17        Constant:
+0:17          false (const bool)
+0:17        true case
+0:18        Branch: Return with expression
+0:18          Constant:
+0:18            0.000000
+0:18            0.000000
+0:18            0.000000
+0:18            0.000000
+0:19      Test condition and select ( temp void)
+0:19        Condition
+0:19        Constant:
+0:19          true (const bool)
+0:19        true case
+0:20        Branch: Return with expression
+0:20          Constant:
+0:20            0.000000
+0:20            0.000000
+0:20            0.000000
+0:20            0.000000
+0:21      Test condition and select ( temp void)
+0:21        Condition
+0:21        Constant:
+0:21          true (const bool)
+0:21        true case
+0:22        Branch: Return with expression
+0:22          Constant:
+0:22            0.000000
+0:22            0.000000
+0:22            0.000000
+0:22            0.000000
 0:2  Function Definition: main( ( temp void)
 0:2    Function Parameters: 
 0:?     Sequence
@@ -156,6 +200,50 @@ gl_FragCoord origin is upper left
 0:14            0.000000
 0:14            0.000000
 0:14            0.000000
+0:15      Test condition and select ( temp void)
+0:15        Condition
+0:15        Constant:
+0:15          true (const bool)
+0:15        true case
+0:16        Branch: Return with expression
+0:16          Constant:
+0:16            0.000000
+0:16            0.000000
+0:16            0.000000
+0:16            0.000000
+0:17      Test condition and select ( temp void)
+0:17        Condition
+0:17        Constant:
+0:17          false (const bool)
+0:17        true case
+0:18        Branch: Return with expression
+0:18          Constant:
+0:18            0.000000
+0:18            0.000000
+0:18            0.000000
+0:18            0.000000
+0:19      Test condition and select ( temp void)
+0:19        Condition
+0:19        Constant:
+0:19          true (const bool)
+0:19        true case
+0:20        Branch: Return with expression
+0:20          Constant:
+0:20            0.000000
+0:20            0.000000
+0:20            0.000000
+0:20            0.000000
+0:21      Test condition and select ( temp void)
+0:21        Condition
+0:21        Constant:
+0:21          true (const bool)
+0:21        true case
+0:22        Branch: Return with expression
+0:22          Constant:
+0:22            0.000000
+0:22            0.000000
+0:22            0.000000
+0:22            0.000000
 0:2  Function Definition: main( ( temp void)
 0:2    Function Parameters: 
 0:?     Sequence
@@ -167,18 +255,18 @@ gl_FragCoord origin is upper left
 
 // Module Version 10000
 // Generated by (magic number): 80001
-// Id's are bound by 38
+// Id's are bound by 50
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 36
+                              EntryPoint Fragment 4  "main" 48
                               ExecutionMode 4 OriginUpperLeft
                               Source HLSL 500
                               Name 4  "main"
                               Name 9  "@main("
-                              Name 36  "@entryPointOutput"
-                              Decorate 36(@entryPointOutput) Location 0
+                              Name 48  "@entryPointOutput"
+                              Decorate 48(@entryPointOutput) Location 0
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -189,12 +277,12 @@ gl_FragCoord origin is upper left
               15:    6(float) Constant 0
               16:    7(fvec4) ConstantComposite 15 15 15 15
               21:    11(bool) ConstantTrue
-              35:             TypePointer Output 7(fvec4)
-36(@entryPointOutput):     35(ptr) Variable Output
+              47:             TypePointer Output 7(fvec4)
+48(@entryPointOutput):     47(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
-              37:    7(fvec4) FunctionCall 9(@main()
-                              Store 36(@entryPointOutput) 37
+              49:    7(fvec4) FunctionCall 9(@main()
+                              Store 48(@entryPointOutput) 49
                               Return
                               FunctionEnd
        9(@main():    7(fvec4) Function None 8
@@ -229,6 +317,26 @@ gl_FragCoord origin is upper left
               31:               Label
                                 ReturnValue 16
               32:             Label
-              34:    7(fvec4) Undef
-                              ReturnValue 34
+                              SelectionMerge 35 None
+                              BranchConditional 21 34 35
+              34:               Label
+                                ReturnValue 16
+              35:             Label
+                              SelectionMerge 38 None
+                              BranchConditional 12 37 38
+              37:               Label
+                                ReturnValue 16
+              38:             Label
+                              SelectionMerge 41 None
+                              BranchConditional 21 40 41
+              40:               Label
+                                ReturnValue 16
+              41:             Label
+                              SelectionMerge 44 None
+                              BranchConditional 21 43 44
+              43:               Label
+                                ReturnValue 16
+              44:             Label
+              46:    7(fvec4) Undef
+                              ReturnValue 46
                               FunctionEnd
index 2977206f4433849ccb12e479da93458bcb20abce..b353eb1eed60ea06a96ac74179828069cb800fb7 100755 (executable)
@@ -12,4 +12,12 @@ float4 main() : SV_TARGET
                return 0.0.xxxx;\r
        if (!1)\r
                return 0.0.xxxx;\r
+    if (0 || 1)\r
+               return 0.0.xxxx;\r
+    if (1 && 0)\r
+               return 0.0.xxxx;\r
+    if (1 || false)\r
+               return 0.0.xxxx;\r
+    if (true && 1)\r
+               return 0.0.xxxx;\r
 }
\ No newline at end of file
index fe0651aa568d8b333e7cbf685b833ffaac9744d6..0251de895f1b7202523cc7a687670aad018b544c 100644 (file)
@@ -148,8 +148,8 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
     // If they are both (non-specialization) constants, they must be folded.
     // (Unless it's the sequence (comma) operator, but that's handled in addComma().)
     //
-    TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
-    TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();
+    TIntermConstantUnion *leftTempConstant = node->getLeft()->getAsConstantUnion();
+    TIntermConstantUnion *rightTempConstant = node->getRight()->getAsConstantUnion();
     if (leftTempConstant && rightTempConstant) {
         TIntermTyped* folded = leftTempConstant->fold(node->getOp(), rightTempConstant);
         if (folded)
@@ -158,7 +158,7 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
 
     // If can propagate spec-constantness and if the operation is an allowed
     // specialization-constant operation, make a spec-constant.
-    if (specConstantPropagates(*left, *right) && isSpecializationOperation(*node))
+    if (specConstantPropagates(*node->getLeft(), *node->getRight()) && isSpecializationOperation(*node))
         node->getWritableType().getQualifier().makeSpecConstant();
 
     return node;