SPV: RelaxedPrecision: Generalize fix #2293 to cover more operations.

This simplifies and enforces use of precision in many more places,
to help avoid accidental loss of RelaxedPrecision through intermediate
operations. Known fixes are:
- ?:
- function return values with mis-matched precision
- precision of function return values when a copy was needed to fix types
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index e0480d1..87a2830 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -2981,7 +2981,8 @@
                 // receive the result, and must later swizzle that into the original
                 // l-value.
                 complexLvalues.push_back(builder.getAccessChain());
-                temporaryLvalues.push_back(builder.createVariable(spv::StorageClassFunction,
+                temporaryLvalues.push_back(builder.createVariable(
+                    spv::NoPrecision, spv::StorageClassFunction,
                     builder.accessChainGetInferredType(), "swizzleTemp"));
                 operands.push_back(temporaryLvalues.back());
             } else {
@@ -3084,7 +3085,7 @@
 
         for (unsigned int i = 0; i < temporaryLvalues.size(); ++i) {
             builder.setAccessChain(complexLvalues[i]);
-            builder.accessChainStore(builder.createLoad(temporaryLvalues[i]));
+            builder.accessChainStore(builder.createLoad(temporaryLvalues[i], spv::NoPrecision));
         }
     }
 
@@ -3201,7 +3202,8 @@
         } else {
             // We need control flow to select the result.
             // TODO: Once SPIR-V OpSelect allows arbitrary types, eliminate this path.
-            result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
+            result = builder.createVariable(TranslatePrecisionDecoration(node->getType()),
+                spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
 
             // Selection control:
             const spv::SelectionControlMask control = TranslateSelectionControl(*node);
@@ -3226,8 +3228,10 @@
     // Execute the one side needed, as per the condition
     const auto executeOneSide = [&]() {
         // Always emit control flow.
-        if (node->getBasicType() != glslang::EbtVoid)
-            result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()));
+        if (node->getBasicType() != glslang::EbtVoid) {
+            result = builder.createVariable(TranslatePrecisionDecoration(node->getType()), spv::StorageClassFunction,
+                convertGlslangToSpvType(node->getType()));
+        }
 
         // Selection control:
         const spv::SelectionControlMask control = TranslateSelectionControl(*node);
@@ -3424,15 +3428,17 @@
         builder.createLoopContinue();
         break;
     case glslang::EOpReturn:
-        if (node->getExpression()) {
+        if (node->getExpression() != nullptr) {
             const glslang::TType& glslangReturnType = node->getExpression()->getType();
             spv::Id returnId = accessChainLoad(glslangReturnType);
-            if (builder.getTypeId(returnId) != currentFunction->getReturnType()) {
+            if (builder.getTypeId(returnId) != currentFunction->getReturnType() ||
+                TranslatePrecisionDecoration(glslangReturnType) != currentFunction->getReturnPrecision()) {
                 builder.clearAccessChain();
-                spv::Id copyId = builder.createVariable(spv::StorageClassFunction, currentFunction->getReturnType());
+                spv::Id copyId = builder.createVariable(currentFunction->getReturnPrecision(),
+                    spv::StorageClassFunction, currentFunction->getReturnType());
                 builder.setAccessChainLValue(copyId);
                 multiTypeStore(glslangReturnType, returnId);
-                returnId = builder.createLoad(copyId);
+                returnId = builder.createLoad(copyId, currentFunction->getReturnPrecision());
             }
             builder.makeReturn(false, returnId);
         } else
@@ -3539,7 +3545,7 @@
                                                                false /* specConst */);
     }
 
-    return builder.createVariable(storageClass, spvType, name, initializer);
+    return builder.createVariable(spv::NoPrecision, storageClass, spvType, name, initializer);
 }
 
 // Return type Id of the sampled type.
@@ -5334,10 +5340,8 @@
             ++lValueCount;
         } else if (writableParam(qualifiers[a])) {
             // need space to hold the copy
-            arg = builder.createVariable(spv::StorageClassFunction,
+            arg = builder.createVariable(function->getParamPrecision(a), spv::StorageClassFunction,
                 builder.getContainedTypeId(function->getParamType(a)), "param");
-            if (function->isReducedPrecisionParam(a))
-                builder.setPrecision(arg, spv::DecorationRelaxedPrecision);
             if (qualifiers[a] == glslang::EvqIn || qualifiers[a] == glslang::EvqInOut) {
                 // need to copy the input into output space
                 builder.setAccessChain(lValues[lValueCount]);
@@ -5348,21 +5352,15 @@
             }
             ++lValueCount;
         } else {
-            const bool argIsRelaxedPrecision = TranslatePrecisionDecoration(*argTypes[a]) ==
-                spv::DecorationRelaxedPrecision;
             // process r-value, which involves a copy for a type mismatch
             if (function->getParamType(a) != convertGlslangToSpvType(*argTypes[a]) ||
-                argIsRelaxedPrecision != function->isReducedPrecisionParam(a))
+                TranslatePrecisionDecoration(*argTypes[a]) != function->getParamPrecision(a))
             {
-                spv::Id argCopy = builder.createVariable(spv::StorageClassFunction, function->getParamType(a), "arg");
-                if (function->isReducedPrecisionParam(a))
-                    builder.setPrecision(argCopy, spv::DecorationRelaxedPrecision);
+                spv::Id argCopy = builder.createVariable(function->getParamPrecision(a), spv::StorageClassFunction, function->getParamType(a), "arg");
                 builder.clearAccessChain();
                 builder.setAccessChainLValue(argCopy);
                 multiTypeStore(*argTypes[a], rValues[rValueCount]);
-                arg = builder.createLoad(argCopy);
-                if (function->isReducedPrecisionParam(a))
-                    builder.setPrecision(arg, spv::DecorationRelaxedPrecision);
+                arg = builder.createLoad(argCopy, function->getParamPrecision(a));
             } else
                 arg = rValues[rValueCount];
             ++rValueCount;
@@ -5381,7 +5379,7 @@
             ++lValueCount;
         else if (writableParam(qualifiers[a])) {
             if (qualifiers[a] == glslang::EvqOut || qualifiers[a] == glslang::EvqInOut) {
-                spv::Id copy = builder.createLoad(spvArgs[a]);
+                spv::Id copy = builder.createLoad(spvArgs[a], spv::NoPrecision);
                 builder.setAccessChain(lValues[lValueCount]);
                 multiTypeStore(*argTypes[a], copy);
             }
diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp
index f884224..fba26ad 100644
--- a/SPIRV/SpvBuilder.cpp
+++ b/SPIRV/SpvBuilder.cpp
@@ -1297,11 +1297,11 @@
 
     // Set up the precisions
     setPrecision(function->getId(), precision);
+    function->setReturnPrecision(precision);
     for (unsigned p = 0; p < (unsigned)decorations.size(); ++p) {
         for (int d = 0; d < (int)decorations[p].size(); ++d) {
             addDecoration(firstParamId + p, decorations[p][d]);
-            if (decorations[p][d] == DecorationRelaxedPrecision)
-                function->addReducedPrecisionParam(p);
+            function->addParamPrecision(p, decorations[p][d]);
         }
     }
 
@@ -1359,7 +1359,7 @@
 }
 
 // Comments in header
-Id Builder::createVariable(StorageClass storageClass, Id type, const char* name, Id initializer)
+Id Builder::createVariable(Decoration precision, StorageClass storageClass, Id type, const char* name, Id initializer)
 {
     Id pointerType = makePointer(storageClass, type);
     Instruction* inst = new Instruction(getUniqueId(), pointerType, OpVariable);
@@ -1381,6 +1381,7 @@
 
     if (name)
         addName(inst->getResultId(), name);
+    setPrecision(inst->getResultId(), precision);
 
     return inst->getResultId();
 }
@@ -1437,7 +1438,8 @@
 }
 
 // Comments in header
-Id Builder::createLoad(Id lValue, spv::MemoryAccessMask memoryAccess, spv::Scope scope, unsigned int alignment)
+Id Builder::createLoad(Id lValue, spv::Decoration precision, spv::MemoryAccessMask memoryAccess,
+    spv::Scope scope, unsigned int alignment)
 {
     Instruction* load = new Instruction(getUniqueId(), getDerefTypeId(lValue), OpLoad);
     load->addIdOperand(lValue);
@@ -1455,6 +1457,7 @@
     }
 
     buildPoint->addInstruction(std::unique_ptr<Instruction>(load));
+    setPrecision(load->getResultId(), precision);
 
     return load->getResultId();
 }
@@ -2677,7 +2680,7 @@
     // If swizzle still exists, it is out-of-order or not full, we must load the target vector,
     // extract and insert elements to perform writeMask and/or swizzle.
     if (accessChain.swizzle.size() > 0) {
-        Id tempBaseId = createLoad(base);
+        Id tempBaseId = createLoad(base, spv::NoPrecision);
         source = createLvalueSwizzle(getTypeId(tempBaseId), tempBaseId, source, accessChain.swizzle);
     }
 
@@ -2716,17 +2719,17 @@
 
             if (constant) {
                 id = createCompositeExtract(accessChain.base, swizzleBase, indexes);
+                setPrecision(id, precision);
             } else {
                 Id lValue = NoResult;
                 if (spvVersion >= Spv_1_4) {
                     // make a new function variable for this r-value, using an initializer,
                     // and mark it as NonWritable so that downstream it can be detected as a lookup
                     // table
-                    lValue = createVariable(StorageClassFunction, getTypeId(accessChain.base), "indexable",
-                        accessChain.base);
+                    lValue = createVariable(NoPrecision, StorageClassFunction, getTypeId(accessChain.base), "indexable", accessChain.base);
                     addDecoration(lValue, DecorationNonWritable);
                 } else {
-                    lValue = createVariable(StorageClassFunction, getTypeId(accessChain.base), "indexable");
+                    lValue = createVariable(NoPrecision, StorageClassFunction, getTypeId(accessChain.base), "indexable");
                     // store into it
                     createStore(accessChain.base, lValue);
                 }
@@ -2735,9 +2738,8 @@
                 accessChain.isRValue = false;
 
                 // load through the access chain
-                id = createLoad(collapseAccessChain());
+                id = createLoad(collapseAccessChain(), precision);
             }
-            setPrecision(id, precision);
         } else
             id = accessChain.base;  // no precision, it was set when this was defined
     } else {
@@ -2756,8 +2758,7 @@
         // loaded image types get decorated. TODO: This should maybe move to
         // createImageTextureFunctionCall.
         addDecoration(id, nonUniform);
-        id = createLoad(id, memoryAccess, scope, alignment);
-        setPrecision(id, precision);
+        id = createLoad(id, precision, memoryAccess, scope, alignment);
         addDecoration(id, nonUniform);
     }
 
diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h
index 71b90d6..ca126d3 100644
--- a/SPIRV/SpvBuilder.h
+++ b/SPIRV/SpvBuilder.h
@@ -347,7 +347,8 @@
     void makeDiscard();
 
     // Create a global or function local or IO variable.
-    Id createVariable(StorageClass, Id type, const char* name = 0, Id initializer = NoResult);
+    Id createVariable(Decoration precision, StorageClass, Id type, const char* name = nullptr,
+        Id initializer = NoResult);
 
     // Create an intermediate with an undefined value.
     Id createUndefined(Id type);
@@ -357,7 +358,8 @@
         spv::Scope scope = spv::ScopeMax, unsigned int alignment = 0);
 
     // Load from an Id and return it
-    Id createLoad(Id lValue, spv::MemoryAccessMask memoryAccess = spv::MemoryAccessMaskNone,
+    Id createLoad(Id lValue, spv::Decoration precision,
+        spv::MemoryAccessMask memoryAccess = spv::MemoryAccessMaskNone,
         spv::Scope scope = spv::ScopeMax, unsigned int alignment = 0);
 
     // Create an OpAccessChain instruction
diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h
index 6146518..868b9bf 100755
--- a/SPIRV/spvIR.h
+++ b/SPIRV/spvIR.h
@@ -352,13 +352,27 @@
     const std::vector<Block*>& getBlocks() const { return blocks; }
     void addLocalVariable(std::unique_ptr<Instruction> inst);
     Id getReturnType() const { return functionInstruction.getTypeId(); }
+    void setReturnPrecision(Decoration precision)
+    {
+        if (precision == DecorationRelaxedPrecision)
+            reducedPrecisionReturn = true;
+    }
+    Decoration getReturnPrecision() const
+        { return reducedPrecisionReturn ? DecorationRelaxedPrecision : NoPrecision; }
 
     void setImplicitThis() { implicitThis = true; }
     bool hasImplicitThis() const { return implicitThis; }
 
-    void addReducedPrecisionParam(int p) { reducedPrecisionParams.insert(p); }
-    bool isReducedPrecisionParam(int p) const
-        { return reducedPrecisionParams.find(p) != reducedPrecisionParams.end(); }
+    void addParamPrecision(unsigned param, Decoration precision)
+    {
+        if (precision == DecorationRelaxedPrecision)
+            reducedPrecisionParams.insert(param);
+    }
+    Decoration getParamPrecision(unsigned param) const
+    {
+        return reducedPrecisionParams.find(param) != reducedPrecisionParams.end() ?
+            DecorationRelaxedPrecision : NoPrecision;
+    }
 
     void dump(std::vector<unsigned int>& out) const
     {
@@ -384,6 +398,7 @@
     std::vector<Instruction*> parameterInstructions;
     std::vector<Block*> blocks;
     bool implicitThis;  // true if this is a member function expecting to be passed a 'this' as the first argument
+    bool reducedPrecisionReturn;
     std::set<int> reducedPrecisionParams;  // list of parameter indexes that need a relaxed precision arg
 };
 
@@ -445,7 +460,8 @@
 // - the OpFunction instruction
 // - all the OpFunctionParameter instructions
 __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParamId, Module& parent)
-    : parent(parent), functionInstruction(id, resultType, OpFunction), implicitThis(false)
+    : parent(parent), functionInstruction(id, resultType, OpFunction), implicitThis(false),
+      reducedPrecisionReturn(false)
 {
     // OpFunction
     functionInstruction.addImmediateOperand(FunctionControlMaskNone);
diff --git a/Test/baseResults/spv.forwardFun.frag.out b/Test/baseResults/spv.forwardFun.frag.out
index e0d749b..4fd7776 100644
--- a/Test/baseResults/spv.forwardFun.frag.out
+++ b/Test/baseResults/spv.forwardFun.frag.out
@@ -1,12 +1,12 @@
 spv.forwardFun.frag
 // Module Version 10000
 // Generated by (magic number): 8000a
-// Id's are bound by 60
+// Id's are bound by 64
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 20 30 36 59
+                              EntryPoint Fragment 4  "main" 20 30 36 63
                               ExecutionMode 4 OriginUpperLeft
                               Source GLSL 140
                               Name 4  "main"
@@ -20,7 +20,7 @@
                               Name 27  "f"
                               Name 30  "gl_FragColor"
                               Name 36  "d"
-                              Name 59  "bigColor"
+                              Name 63  "bigColor"
                               Decorate 10(unreachableReturn() RelaxedPrecision
                               Decorate 16(foo(vf4;) RelaxedPrecision
                               Decorate 15(bar) RelaxedPrecision
@@ -39,10 +39,14 @@
                               Decorate 33 RelaxedPrecision
                               Decorate 36(d) RelaxedPrecision
                               Decorate 37 RelaxedPrecision
-                              Decorate 52 RelaxedPrecision
-                              Decorate 55 RelaxedPrecision
+                              Decorate 44 RelaxedPrecision
+                              Decorate 45 RelaxedPrecision
+                              Decorate 49 RelaxedPrecision
+                              Decorate 50 RelaxedPrecision
                               Decorate 56 RelaxedPrecision
-                              Decorate 59(bigColor) RelaxedPrecision
+                              Decorate 59 RelaxedPrecision
+                              Decorate 60 RelaxedPrecision
+                              Decorate 63(bigColor) RelaxedPrecision
                2:             TypeVoid
                3:             TypeFunction 2
                8:             TypeFloat 32
@@ -60,11 +64,11 @@
               38:    8(float) Constant 1082549862
               39:             TypeBool
               43:    8(float) Constant 1067030938
-              46:    8(float) Constant 1083179008
-              49:             TypeInt 32 0
-              50:     49(int) Constant 0
-              53:     49(int) Constant 1
-    59(bigColor):     19(ptr) Variable Input
+              48:    8(float) Constant 1083179008
+              53:             TypeInt 32 0
+              54:     53(int) Constant 0
+              57:     53(int) Constant 1
+    63(bigColor):     19(ptr) Variable Input
          4(main):           2 Function None 3
                5:             Label
        18(color):     13(ptr) Variable Function
@@ -90,25 +94,31 @@
                               FunctionEnd
 10(unreachableReturn():    8(float) Function None 9
               11:             Label
+              44:     26(ptr) Variable Function
+              49:     26(ptr) Variable Function
               34:           2 FunctionCall 6(bar()
               37:    8(float) Load 36(d)
               40:    39(bool) FOrdLessThan 37 38
                               SelectionMerge 42 None
-                              BranchConditional 40 41 45
+                              BranchConditional 40 41 47
               41:               Label
-                                ReturnValue 43
-              45:               Label
-                                ReturnValue 46
+                                Store 44 43
+              45:    8(float)   Load 44
+                                ReturnValue 45
+              47:               Label
+                                Store 49 48
+              50:    8(float)   Load 49
+                                ReturnValue 50
               42:             Label
                               Unreachable
                               FunctionEnd
     16(foo(vf4;):    8(float) Function None 14
          15(bar):     13(ptr) FunctionParameter
               17:             Label
-              51:     26(ptr) AccessChain 15(bar) 50
-              52:    8(float) Load 51
-              54:     26(ptr) AccessChain 15(bar) 53
-              55:    8(float) Load 54
-              56:    8(float) FAdd 52 55
-                              ReturnValue 56
+              55:     26(ptr) AccessChain 15(bar) 54
+              56:    8(float) Load 55
+              58:     26(ptr) AccessChain 15(bar) 57
+              59:    8(float) Load 58
+              60:    8(float) FAdd 56 59
+                              ReturnValue 60
                               FunctionEnd
diff --git a/Test/baseResults/spv.precision.frag.out b/Test/baseResults/spv.precision.frag.out
index 9b2b860..919a30c 100644
--- a/Test/baseResults/spv.precision.frag.out
+++ b/Test/baseResults/spv.precision.frag.out
@@ -1,12 +1,12 @@
 spv.precision.frag
 // Module Version 10000
 // Generated by (magic number): 8000a
-// Id's are bound by 127
+// Id's are bound by 146
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 23 59 61 73 116
+                              EntryPoint Fragment 4  "main" 23 62 64 76 119
                               ExecutionMode 4 OriginUpperLeft
                               Source ESSL 310
                               Name 4  "main"
@@ -15,72 +15,83 @@
                               Name 19  "boolfun(vb2;"
                               Name 18  "bv2"
                               Name 23  "highfin"
-                              Name 38  "sum"
-                              Name 40  "uniform_medium"
-                              Name 42  "uniform_high"
-                              Name 48  "uniform_low"
-                              Name 53  "arg1"
-                              Name 55  "arg2"
-                              Name 57  "d"
-                              Name 59  "lowfin"
-                              Name 61  "mediumfin"
-                              Name 65  "global_highp"
-                              Name 69  "local_highp"
-                              Name 73  "mediumfout"
-                              Name 104  "ub2"
-                              Name 105  "param"
-                              Name 114  "S"
-                              MemberName 114(S) 0  "a"
-                              MemberName 114(S) 1  "b"
-                              Name 116  "s"
+                              Name 41  "sum"
+                              Name 43  "uniform_medium"
+                              Name 45  "uniform_high"
+                              Name 51  "uniform_low"
+                              Name 56  "arg1"
+                              Name 58  "arg2"
+                              Name 60  "d"
+                              Name 62  "lowfin"
+                              Name 64  "mediumfin"
+                              Name 68  "global_highp"
+                              Name 72  "local_highp"
+                              Name 76  "mediumfout"
+                              Name 107  "ub2"
+                              Name 108  "param"
+                              Name 117  "S"
+                              MemberName 117(S) 0  "a"
+                              MemberName 117(S) 1  "b"
+                              Name 119  "s"
                               Decorate 12(foo(vf3;) RelaxedPrecision
                               Decorate 11(mv3) RelaxedPrecision
-                              Decorate 38(sum) RelaxedPrecision
-                              Decorate 40(uniform_medium) RelaxedPrecision
-                              Decorate 41 RelaxedPrecision
-                              Decorate 46 RelaxedPrecision
-                              Decorate 48(uniform_low) RelaxedPrecision
+                              Decorate 27 RelaxedPrecision
+                              Decorate 28 RelaxedPrecision
+                              Decorate 41(sum) RelaxedPrecision
+                              Decorate 43(uniform_medium) RelaxedPrecision
+                              Decorate 44 RelaxedPrecision
                               Decorate 49 RelaxedPrecision
-                              Decorate 50 RelaxedPrecision
-                              Decorate 51 RelaxedPrecision
-                              Decorate 53(arg1) RelaxedPrecision
-                              Decorate 55(arg2) RelaxedPrecision
-                              Decorate 57(d) RelaxedPrecision
-                              Decorate 59(lowfin) RelaxedPrecision
-                              Decorate 60 RelaxedPrecision
-                              Decorate 61(mediumfin) RelaxedPrecision
-                              Decorate 62 RelaxedPrecision
+                              Decorate 51(uniform_low) RelaxedPrecision
+                              Decorate 52 RelaxedPrecision
+                              Decorate 53 RelaxedPrecision
+                              Decorate 54 RelaxedPrecision
+                              Decorate 56(arg1) RelaxedPrecision
+                              Decorate 58(arg2) RelaxedPrecision
+                              Decorate 60(d) RelaxedPrecision
+                              Decorate 62(lowfin) RelaxedPrecision
                               Decorate 63 RelaxedPrecision
-                              Decorate 73(mediumfout) RelaxedPrecision
-                              Decorate 74 RelaxedPrecision
-                              Decorate 75 RelaxedPrecision
-                              Decorate 76 RelaxedPrecision
+                              Decorate 64(mediumfin) RelaxedPrecision
+                              Decorate 65 RelaxedPrecision
+                              Decorate 66 RelaxedPrecision
+                              Decorate 76(mediumfout) RelaxedPrecision
                               Decorate 77 RelaxedPrecision
                               Decorate 78 RelaxedPrecision
                               Decorate 79 RelaxedPrecision
-                              Decorate 83 RelaxedPrecision
-                              Decorate 85 RelaxedPrecision
-                              Decorate 87 RelaxedPrecision
+                              Decorate 80 RelaxedPrecision
+                              Decorate 81 RelaxedPrecision
+                              Decorate 82 RelaxedPrecision
+                              Decorate 86 RelaxedPrecision
                               Decorate 88 RelaxedPrecision
                               Decorate 90 RelaxedPrecision
                               Decorate 91 RelaxedPrecision
+                              Decorate 93 RelaxedPrecision
                               Decorate 94 RelaxedPrecision
-                              Decorate 95 RelaxedPrecision
-                              Decorate 96 RelaxedPrecision
                               Decorate 97 RelaxedPrecision
                               Decorate 98 RelaxedPrecision
                               Decorate 99 RelaxedPrecision
                               Decorate 100 RelaxedPrecision
                               Decorate 101 RelaxedPrecision
                               Decorate 102 RelaxedPrecision
-                              Decorate 110 RelaxedPrecision
-                              Decorate 112 RelaxedPrecision
+                              Decorate 103 RelaxedPrecision
+                              Decorate 104 RelaxedPrecision
+                              Decorate 105 RelaxedPrecision
                               Decorate 113 RelaxedPrecision
-                              MemberDecorate 114(S) 1 RelaxedPrecision
-                              Decorate 120 RelaxedPrecision
-                              Decorate 124 RelaxedPrecision
-                              Decorate 125 RelaxedPrecision
-                              Decorate 126 RelaxedPrecision
+                              Decorate 115 RelaxedPrecision
+                              Decorate 116 RelaxedPrecision
+                              MemberDecorate 117(S) 1 RelaxedPrecision
+                              Decorate 123 RelaxedPrecision
+                              Decorate 127 RelaxedPrecision
+                              Decorate 128 RelaxedPrecision
+                              Decorate 129 RelaxedPrecision
+                              Decorate 130 RelaxedPrecision
+                              Decorate 131 RelaxedPrecision
+                              Decorate 132 RelaxedPrecision
+                              Decorate 135 RelaxedPrecision
+                              Decorate 139 RelaxedPrecision
+                              Decorate 140 RelaxedPrecision
+                              Decorate 143 RelaxedPrecision
+                              Decorate 144 RelaxedPrecision
+                              Decorate 145 RelaxedPrecision
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -95,134 +106,161 @@
               21:             TypeVector 6(float) 4
               22:             TypePointer Input 21(fvec4)
      23(highfin):     22(ptr) Variable Input
-              29:    14(bool) ConstantFalse
-              30:    14(bool) ConstantTrue
-              31:   15(bvec2) ConstantComposite 29 30
-              36:             TypeInt 32 1
-              37:             TypePointer Function 36(int)
-              39:             TypePointer Private 36(int)
-40(uniform_medium):     39(ptr) Variable Private
-42(uniform_high):     39(ptr) Variable Private
- 48(uniform_low):     39(ptr) Variable Private
-              52:             TypePointer Function 6(float)
-              54:    6(float) Constant 1078774989
-              56:    6(float) Constant 1232730691
-              58:             TypePointer Input 6(float)
-      59(lowfin):     58(ptr) Variable Input
-   61(mediumfin):     58(ptr) Variable Input
-              64:             TypePointer Private 6(float)
-65(global_highp):     64(ptr) Variable Private
-              68:             TypePointer Function 21(fvec4)
-              72:             TypePointer Output 21(fvec4)
-  73(mediumfout):     72(ptr) Variable Output
-              82:     36(int) Constant 4
-              84:             TypeVector 36(int) 2
-              92:             TypeInt 32 0
-              93:     92(int) Constant 0
-             103:             TypePointer Private 15(bvec2)
-        104(ub2):    103(ptr) Variable Private
-             111:    6(float) Constant 1065353216
-          114(S):             TypeStruct 6(float) 6(float)
-             115:             TypePointer Input 114(S)
-          116(s):    115(ptr) Variable Input
-             117:     36(int) Constant 0
-             122:     36(int) Constant 1
+              26:             TypePointer Function 9(fvec2)
+              32:    14(bool) ConstantFalse
+              33:    14(bool) ConstantTrue
+              34:   15(bvec2) ConstantComposite 32 33
+              39:             TypeInt 32 1
+              40:             TypePointer Function 39(int)
+              42:             TypePointer Private 39(int)
+43(uniform_medium):     42(ptr) Variable Private
+45(uniform_high):     42(ptr) Variable Private
+ 51(uniform_low):     42(ptr) Variable Private
+              55:             TypePointer Function 6(float)
+              57:    6(float) Constant 1078774989
+              59:    6(float) Constant 1232730691
+              61:             TypePointer Input 6(float)
+      62(lowfin):     61(ptr) Variable Input
+   64(mediumfin):     61(ptr) Variable Input
+              67:             TypePointer Private 6(float)
+68(global_highp):     67(ptr) Variable Private
+              71:             TypePointer Function 21(fvec4)
+              75:             TypePointer Output 21(fvec4)
+  76(mediumfout):     75(ptr) Variable Output
+              85:     39(int) Constant 4
+              87:             TypeVector 39(int) 2
+              95:             TypeInt 32 0
+              96:     95(int) Constant 0
+             106:             TypePointer Private 15(bvec2)
+        107(ub2):    106(ptr) Variable Private
+             114:    6(float) Constant 1065353216
+          117(S):             TypeStruct 6(float) 6(float)
+             118:             TypePointer Input 117(S)
+          119(s):    118(ptr) Variable Input
+             120:     39(int) Constant 0
+             125:     39(int) Constant 1
+             133:    6(float) Constant 1082549862
+             138:    6(float) Constant 1073741824
+             142:    6(float) Constant 1077936128
          4(main):           2 Function None 3
                5:             Label
-         38(sum):     37(ptr) Variable Function
-        53(arg1):     52(ptr) Variable Function
-        55(arg2):     52(ptr) Variable Function
-           57(d):     52(ptr) Variable Function
- 69(local_highp):     68(ptr) Variable Function
-      105(param):     16(ptr) Variable Function
-              41:     36(int) Load 40(uniform_medium)
-              43:     36(int) Load 42(uniform_high)
-              44:     36(int) IAdd 41 43
-                              Store 38(sum) 44
-              45:     36(int) Load 42(uniform_high)
-              46:     36(int) Load 38(sum)
-              47:     36(int) IAdd 46 45
-                              Store 38(sum) 47
-              49:     36(int) Load 48(uniform_low)
-              50:     36(int) Load 38(sum)
-              51:     36(int) IAdd 50 49
-                              Store 38(sum) 51
-                              Store 53(arg1) 54
-                              Store 55(arg2) 56
-              60:    6(float) Load 59(lowfin)
-              62:    6(float) Load 61(mediumfin)
-              63:    6(float) ExtInst 1(GLSL.std.450) 67(Distance) 60 62
-                              Store 57(d) 63
-              66:   21(fvec4) Load 23(highfin)
-              67:    6(float) ExtInst 1(GLSL.std.450) 66(Length) 66
-                              Store 65(global_highp) 67
-              70:    6(float) Load 65(global_highp)
-              71:   21(fvec4) CompositeConstruct 70 70 70 70
-                              Store 69(local_highp) 71
-              74:    6(float) Load 57(d)
-              75:    6(float) ExtInst 1(GLSL.std.450) 13(Sin) 74
-              76:   21(fvec4) CompositeConstruct 75 75 75 75
-              77:    6(float) Load 55(arg2)
-              78:   21(fvec4) CompositeConstruct 77 77 77 77
-              79:   21(fvec4) FAdd 76 78
-              80:   21(fvec4) Load 69(local_highp)
-              81:   21(fvec4) FAdd 79 80
-                              Store 73(mediumfout) 81
-              83:     36(int) Load 48(uniform_low)
-              85:   84(ivec2) CompositeConstruct 83 83
-              86:     36(int) Load 42(uniform_high)
-              87:   84(ivec2) CompositeConstruct 86 86
-              88:   84(ivec2) IMul 85 87
-              89:     36(int) Load 42(uniform_high)
-              90:   84(ivec2) CompositeConstruct 89 89
-              91:   84(ivec2) IAdd 88 90
-              94:     36(int) CompositeExtract 91 0
-              95:     36(int) IAdd 82 94
-              96:     36(int) Load 38(sum)
-              97:     36(int) IAdd 96 95
-                              Store 38(sum) 97
-              98:     36(int) Load 38(sum)
-              99:    6(float) ConvertSToF 98
-             100:   21(fvec4) CompositeConstruct 99 99 99 99
-             101:   21(fvec4) Load 73(mediumfout)
-             102:   21(fvec4) FAdd 101 100
-                              Store 73(mediumfout) 102
-             106:   15(bvec2) Load 104(ub2)
-                              Store 105(param) 106
-             107:    14(bool) FunctionCall 19(boolfun(vb2;) 105(param)
-                              SelectionMerge 109 None
-                              BranchConditional 107 108 109
-             108:               Label
-             110:   21(fvec4)   Load 73(mediumfout)
-             112:   21(fvec4)   CompositeConstruct 111 111 111 111
-             113:   21(fvec4)   FAdd 110 112
-                                Store 73(mediumfout) 113
-                                Branch 109
-             109:             Label
-             118:     58(ptr) AccessChain 116(s) 117
-             119:    6(float) Load 118
-             120:   21(fvec4) Load 73(mediumfout)
-             121:   21(fvec4) VectorTimesScalar 120 119
-                              Store 73(mediumfout) 121
-             123:     58(ptr) AccessChain 116(s) 122
-             124:    6(float) Load 123
-             125:   21(fvec4) Load 73(mediumfout)
-             126:   21(fvec4) VectorTimesScalar 125 124
-                              Store 73(mediumfout) 126
+         41(sum):     40(ptr) Variable Function
+        56(arg1):     55(ptr) Variable Function
+        58(arg2):     55(ptr) Variable Function
+           60(d):     55(ptr) Variable Function
+ 72(local_highp):     71(ptr) Variable Function
+      108(param):     16(ptr) Variable Function
+             135:     71(ptr) Variable Function
+              44:     39(int) Load 43(uniform_medium)
+              46:     39(int) Load 45(uniform_high)
+              47:     39(int) IAdd 44 46
+                              Store 41(sum) 47
+              48:     39(int) Load 45(uniform_high)
+              49:     39(int) Load 41(sum)
+              50:     39(int) IAdd 49 48
+                              Store 41(sum) 50
+              52:     39(int) Load 51(uniform_low)
+              53:     39(int) Load 41(sum)
+              54:     39(int) IAdd 53 52
+                              Store 41(sum) 54
+                              Store 56(arg1) 57
+                              Store 58(arg2) 59
+              63:    6(float) Load 62(lowfin)
+              65:    6(float) Load 64(mediumfin)
+              66:    6(float) ExtInst 1(GLSL.std.450) 67(Distance) 63 65
+                              Store 60(d) 66
+              69:   21(fvec4) Load 23(highfin)
+              70:    6(float) ExtInst 1(GLSL.std.450) 66(Length) 69
+                              Store 68(global_highp) 70
+              73:    6(float) Load 68(global_highp)
+              74:   21(fvec4) CompositeConstruct 73 73 73 73
+                              Store 72(local_highp) 74
+              77:    6(float) Load 60(d)
+              78:    6(float) ExtInst 1(GLSL.std.450) 13(Sin) 77
+              79:   21(fvec4) CompositeConstruct 78 78 78 78
+              80:    6(float) Load 58(arg2)
+              81:   21(fvec4) CompositeConstruct 80 80 80 80
+              82:   21(fvec4) FAdd 79 81
+              83:   21(fvec4) Load 72(local_highp)
+              84:   21(fvec4) FAdd 82 83
+                              Store 76(mediumfout) 84
+              86:     39(int) Load 51(uniform_low)
+              88:   87(ivec2) CompositeConstruct 86 86
+              89:     39(int) Load 45(uniform_high)
+              90:   87(ivec2) CompositeConstruct 89 89
+              91:   87(ivec2) IMul 88 90
+              92:     39(int) Load 45(uniform_high)
+              93:   87(ivec2) CompositeConstruct 92 92
+              94:   87(ivec2) IAdd 91 93
+              97:     39(int) CompositeExtract 94 0
+              98:     39(int) IAdd 85 97
+              99:     39(int) Load 41(sum)
+             100:     39(int) IAdd 99 98
+                              Store 41(sum) 100
+             101:     39(int) Load 41(sum)
+             102:    6(float) ConvertSToF 101
+             103:   21(fvec4) CompositeConstruct 102 102 102 102
+             104:   21(fvec4) Load 76(mediumfout)
+             105:   21(fvec4) FAdd 104 103
+                              Store 76(mediumfout) 105
+             109:   15(bvec2) Load 107(ub2)
+                              Store 108(param) 109
+             110:    14(bool) FunctionCall 19(boolfun(vb2;) 108(param)
+                              SelectionMerge 112 None
+                              BranchConditional 110 111 112
+             111:               Label
+             113:   21(fvec4)   Load 76(mediumfout)
+             115:   21(fvec4)   CompositeConstruct 114 114 114 114
+             116:   21(fvec4)   FAdd 113 115
+                                Store 76(mediumfout) 116
+                                Branch 112
+             112:             Label
+             121:     61(ptr) AccessChain 119(s) 120
+             122:    6(float) Load 121
+             123:   21(fvec4) Load 76(mediumfout)
+             124:   21(fvec4) VectorTimesScalar 123 122
+                              Store 76(mediumfout) 124
+             126:     61(ptr) AccessChain 119(s) 125
+             127:    6(float) Load 126
+             128:   21(fvec4) Load 76(mediumfout)
+             129:   21(fvec4) VectorTimesScalar 128 127
+                              Store 76(mediumfout) 129
+             130:    6(float) Load 64(mediumfin)
+             131:    6(float) Load 64(mediumfin)
+             132:    6(float) FMul 130 131
+             134:    14(bool) FOrdGreaterThan 132 133
+                              SelectionMerge 137 None
+                              BranchConditional 134 136 141
+             136:               Label
+             139:   21(fvec4)   Load 76(mediumfout)
+             140:   21(fvec4)   VectorTimesScalar 139 138
+                                Store 135 140
+                                Branch 137
+             141:               Label
+             143:   21(fvec4)   Load 76(mediumfout)
+             144:   21(fvec4)   VectorTimesScalar 143 142
+                                Store 135 144
+                                Branch 137
+             137:             Label
+             145:   21(fvec4) Load 135
+                              Store 76(mediumfout) 145
                               Return
                               FunctionEnd
     12(foo(vf3;):    9(fvec2) Function None 10
          11(mv3):      8(ptr) FunctionParameter
               13:             Label
+              27:     26(ptr) Variable Function
               24:   21(fvec4) Load 23(highfin)
               25:    9(fvec2) VectorShuffle 24 24 0 1
-                              ReturnValue 25
+                              Store 27 25
+              28:    9(fvec2) Load 27
+                              ReturnValue 28
                               FunctionEnd
 19(boolfun(vb2;):    14(bool) Function None 17
          18(bv2):     16(ptr) FunctionParameter
               20:             Label
-              28:   15(bvec2) Load 18(bv2)
-              32:   15(bvec2) LogicalEqual 28 31
-              33:    14(bool) All 32
-                              ReturnValue 33
+              31:   15(bvec2) Load 18(bv2)
+              35:   15(bvec2) LogicalEqual 31 34
+              36:    14(bool) All 35
+                              ReturnValue 36
                               FunctionEnd
diff --git a/Test/baseResults/spv.precisionArgs.frag.out b/Test/baseResults/spv.precisionArgs.frag.out
index b670fc8..ae54a58 100755
--- a/Test/baseResults/spv.precisionArgs.frag.out
+++ b/Test/baseResults/spv.precisionArgs.frag.out
@@ -1,7 +1,7 @@
 spv.precisionArgs.frag
 // Module Version 10000
 // Generated by (magic number): 8000a
-// Id's are bound by 42
+// Id's are bound by 83
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
@@ -16,66 +16,109 @@
                               Name 16  "foo(f1;f1;"
                               Name 14  "f"
                               Name 15  "g"
-                              Name 18  "aM"
-                              Name 20  "bM"
-                              Name 22  "arg"
-                              Name 25  "aH"
-                              Name 27  "bH"
-                              Name 29  "arg"
-                              Name 32  "param"
-                              Name 34  "param"
-                              Name 37  "param"
-                              Name 39  "param"
+                              Name 20  "retM(f1;"
+                              Name 19  "x"
+                              Name 23  "retH(f1;"
+                              Name 22  "x"
+                              Name 26  "retHM(f1;"
+                              Name 25  "x"
+                              Name 29  "retMH(f1;"
+                              Name 28  "x"
+                              Name 47  "aM"
+                              Name 49  "bM"
+                              Name 51  "arg"
+                              Name 54  "aH"
+                              Name 56  "bH"
+                              Name 58  "arg"
+                              Name 61  "param"
+                              Name 63  "param"
+                              Name 66  "param"
+                              Name 68  "param"
+                              Name 71  "param"
+                              Name 74  "param"
+                              Name 77  "param"
+                              Name 80  "param"
                               Decorate 8(f) RelaxedPrecision
                               Decorate 14(f) RelaxedPrecision
-                              Decorate 18(aM) RelaxedPrecision
-                              Decorate 19 RelaxedPrecision
-                              Decorate 20(bM) RelaxedPrecision
-                              Decorate 21 RelaxedPrecision
-                              Decorate 29(arg) RelaxedPrecision
-                              Decorate 30 RelaxedPrecision
-                              Decorate 32(param) RelaxedPrecision
-                              Decorate 33 RelaxedPrecision
-                              Decorate 35 RelaxedPrecision
-                              Decorate 37(param) RelaxedPrecision
+                              Decorate 20(retM(f1;) RelaxedPrecision
+                              Decorate 19(x) RelaxedPrecision
+                              Decorate 26(retHM(f1;) RelaxedPrecision
+                              Decorate 28(x) RelaxedPrecision
+                              Decorate 31 RelaxedPrecision
+                              Decorate 38 RelaxedPrecision
+                              Decorate 39 RelaxedPrecision
+                              Decorate 42 RelaxedPrecision
+                              Decorate 47(aM) RelaxedPrecision
+                              Decorate 48 RelaxedPrecision
+                              Decorate 49(bM) RelaxedPrecision
+                              Decorate 50 RelaxedPrecision
+                              Decorate 58(arg) RelaxedPrecision
+                              Decorate 59 RelaxedPrecision
+                              Decorate 61(param) RelaxedPrecision
+                              Decorate 62 RelaxedPrecision
+                              Decorate 64 RelaxedPrecision
+                              Decorate 66(param) RelaxedPrecision
+                              Decorate 71(param) RelaxedPrecision
+                              Decorate 72 RelaxedPrecision
+                              Decorate 73 RelaxedPrecision
+                              Decorate 79 RelaxedPrecision
+                              Decorate 80(param) RelaxedPrecision
+                              Decorate 81 RelaxedPrecision
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
                7:             TypeFunction 2 6(float) 6(float)
               12:             TypePointer Function 6(float)
               13:             TypeFunction 2 12(ptr) 12(ptr)
+              18:             TypeFunction 6(float) 12(ptr)
          4(main):           2 Function None 3
                5:             Label
-          18(aM):     12(ptr) Variable Function
-          20(bM):     12(ptr) Variable Function
-         22(arg):     12(ptr) Variable Function
-          25(aH):     12(ptr) Variable Function
-          27(bH):     12(ptr) Variable Function
-         29(arg):     12(ptr) Variable Function
-       32(param):     12(ptr) Variable Function
-       34(param):     12(ptr) Variable Function
-       37(param):     12(ptr) Variable Function
-       39(param):     12(ptr) Variable Function
-              19:    6(float) Load 18(aM)
-              21:    6(float) Load 20(bM)
-                              Store 22(arg) 21
-              23:    6(float) Load 22(arg)
-              24:           2 FunctionCall 10(fooConst(f1;f1;) 19 23
-              26:    6(float) Load 25(aH)
-              28:    6(float) Load 27(bH)
-                              Store 29(arg) 26
-              30:    6(float) Load 29(arg)
-              31:           2 FunctionCall 10(fooConst(f1;f1;) 30 28
-              33:    6(float) Load 18(aM)
-                              Store 32(param) 33
-              35:    6(float) Load 20(bM)
-                              Store 34(param) 35
-              36:           2 FunctionCall 16(foo(f1;f1;) 32(param) 34(param)
-              38:    6(float) Load 25(aH)
-                              Store 37(param) 38
-              40:    6(float) Load 27(bH)
-                              Store 39(param) 40
-              41:           2 FunctionCall 16(foo(f1;f1;) 37(param) 39(param)
+          47(aM):     12(ptr) Variable Function
+          49(bM):     12(ptr) Variable Function
+         51(arg):     12(ptr) Variable Function
+          54(aH):     12(ptr) Variable Function
+          56(bH):     12(ptr) Variable Function
+         58(arg):     12(ptr) Variable Function
+       61(param):     12(ptr) Variable Function
+       63(param):     12(ptr) Variable Function
+       66(param):     12(ptr) Variable Function
+       68(param):     12(ptr) Variable Function
+       71(param):     12(ptr) Variable Function
+       74(param):     12(ptr) Variable Function
+       77(param):     12(ptr) Variable Function
+       80(param):     12(ptr) Variable Function
+              48:    6(float) Load 47(aM)
+              50:    6(float) Load 49(bM)
+                              Store 51(arg) 50
+              52:    6(float) Load 51(arg)
+              53:           2 FunctionCall 10(fooConst(f1;f1;) 48 52
+              55:    6(float) Load 54(aH)
+              57:    6(float) Load 56(bH)
+                              Store 58(arg) 55
+              59:    6(float) Load 58(arg)
+              60:           2 FunctionCall 10(fooConst(f1;f1;) 59 57
+              62:    6(float) Load 47(aM)
+                              Store 61(param) 62
+              64:    6(float) Load 49(bM)
+                              Store 63(param) 64
+              65:           2 FunctionCall 16(foo(f1;f1;) 61(param) 63(param)
+              67:    6(float) Load 54(aH)
+                              Store 66(param) 67
+              69:    6(float) Load 56(bH)
+                              Store 68(param) 69
+              70:           2 FunctionCall 16(foo(f1;f1;) 66(param) 68(param)
+              72:    6(float) Load 47(aM)
+                              Store 71(param) 72
+              73:    6(float) FunctionCall 20(retM(f1;) 71(param)
+              75:    6(float) Load 54(aH)
+                              Store 74(param) 75
+              76:    6(float) FunctionCall 23(retH(f1;) 74(param)
+              78:    6(float) Load 54(aH)
+                              Store 77(param) 78
+              79:    6(float) FunctionCall 26(retHM(f1;) 77(param)
+              81:    6(float) Load 47(aM)
+                              Store 80(param) 81
+              82:    6(float) FunctionCall 29(retMH(f1;) 80(param)
                               Return
                               FunctionEnd
 10(fooConst(f1;f1;):           2 Function None 7
@@ -90,3 +133,33 @@
               17:             Label
                               Return
                               FunctionEnd
+    20(retM(f1;):    6(float) Function None 18
+           19(x):     12(ptr) FunctionParameter
+              21:             Label
+              31:    6(float) Load 19(x)
+                              ReturnValue 31
+                              FunctionEnd
+    23(retH(f1;):    6(float) Function None 18
+           22(x):     12(ptr) FunctionParameter
+              24:             Label
+              34:    6(float) Load 22(x)
+                              ReturnValue 34
+                              FunctionEnd
+   26(retHM(f1;):    6(float) Function None 18
+           25(x):     12(ptr) FunctionParameter
+              27:             Label
+              38:     12(ptr) Variable Function
+              37:    6(float) Load 25(x)
+                              Store 38 37
+              39:    6(float) Load 38
+                              ReturnValue 39
+                              FunctionEnd
+   29(retMH(f1;):    6(float) Function None 18
+           28(x):     12(ptr) FunctionParameter
+              30:             Label
+              43:     12(ptr) Variable Function
+              42:    6(float) Load 28(x)
+                              Store 43 42
+              44:    6(float) Load 43
+                              ReturnValue 44
+                              FunctionEnd
diff --git a/Test/baseResults/spv.switch.frag.out b/Test/baseResults/spv.switch.frag.out
index cd6dde2..796b6ce 100644
--- a/Test/baseResults/spv.switch.frag.out
+++ b/Test/baseResults/spv.switch.frag.out
@@ -5,12 +5,12 @@
 
 // Module Version 10000
 // Generated by (magic number): 8000a
-// Id's are bound by 269
+// Id's are bound by 275
 
                               Capability Shader
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint Fragment 4  "main" 62 75 129 227 233
+                              EntryPoint Fragment 4  "main" 68 81 135 233 239
                               ExecutionMode 4 OriginUpperLeft
                               Source ESSL 310
                               Name 4  "main"
@@ -22,21 +22,21 @@
                               Name 17  "v1"
                               Name 18  "v2"
                               Name 19  "i1"
-                              Name 60  "local"
-                              Name 62  "c"
-                              Name 73  "f"
-                              Name 75  "x"
-                              Name 129  "d"
-                              Name 155  "i"
-                              Name 175  "j"
-                              Name 227  "color"
-                              Name 233  "v"
-                              Name 234  "param"
-                              Name 236  "param"
-                              Name 238  "param"
-                              Name 246  "param"
-                              Name 248  "param"
-                              Name 250  "param"
+                              Name 66  "local"
+                              Name 68  "c"
+                              Name 79  "f"
+                              Name 81  "x"
+                              Name 135  "d"
+                              Name 161  "i"
+                              Name 181  "j"
+                              Name 233  "color"
+                              Name 239  "v"
+                              Name 240  "param"
+                              Name 242  "param"
+                              Name 244  "param"
+                              Name 252  "param"
+                              Name 254  "param"
+                              Name 256  "param"
                               Decorate 15(foo1(vf4;vf4;i1;) RelaxedPrecision
                               Decorate 12(v1) RelaxedPrecision
                               Decorate 13(v2) RelaxedPrecision
@@ -51,131 +51,137 @@
                               Decorate 31 RelaxedPrecision
                               Decorate 32 RelaxedPrecision
                               Decorate 33 RelaxedPrecision
-                              Decorate 40 RelaxedPrecision
-                              Decorate 46 RelaxedPrecision
-                              Decorate 51 RelaxedPrecision
+                              Decorate 38 RelaxedPrecision
+                              Decorate 39 RelaxedPrecision
+                              Decorate 42 RelaxedPrecision
+                              Decorate 48 RelaxedPrecision
+                              Decorate 52 RelaxedPrecision
                               Decorate 53 RelaxedPrecision
-                              Decorate 54 RelaxedPrecision
                               Decorate 55 RelaxedPrecision
-                              Decorate 60(local) RelaxedPrecision
-                              Decorate 62(c) RelaxedPrecision
-                              Decorate 62(c) Flat
+                              Decorate 57 RelaxedPrecision
+                              Decorate 58 RelaxedPrecision
+                              Decorate 59 RelaxedPrecision
+                              Decorate 62 RelaxedPrecision
                               Decorate 63 RelaxedPrecision
-                              Decorate 64 RelaxedPrecision
-                              Decorate 66 RelaxedPrecision
-                              Decorate 67 RelaxedPrecision
-                              Decorate 73(f) RelaxedPrecision
-                              Decorate 75(x) RelaxedPrecision
-                              Decorate 76 RelaxedPrecision
-                              Decorate 77 RelaxedPrecision
-                              Decorate 79 RelaxedPrecision
-                              Decorate 80 RelaxedPrecision
+                              Decorate 66(local) RelaxedPrecision
+                              Decorate 68(c) RelaxedPrecision
+                              Decorate 68(c) Flat
+                              Decorate 69 RelaxedPrecision
+                              Decorate 70 RelaxedPrecision
+                              Decorate 72 RelaxedPrecision
+                              Decorate 73 RelaxedPrecision
+                              Decorate 79(f) RelaxedPrecision
+                              Decorate 81(x) RelaxedPrecision
                               Decorate 82 RelaxedPrecision
                               Decorate 83 RelaxedPrecision
                               Decorate 85 RelaxedPrecision
-                              Decorate 90 RelaxedPrecision
+                              Decorate 86 RelaxedPrecision
+                              Decorate 88 RelaxedPrecision
+                              Decorate 89 RelaxedPrecision
                               Decorate 91 RelaxedPrecision
-                              Decorate 92 RelaxedPrecision
-                              Decorate 93 RelaxedPrecision
-                              Decorate 94 RelaxedPrecision
-                              Decorate 95 RelaxedPrecision
                               Decorate 96 RelaxedPrecision
                               Decorate 97 RelaxedPrecision
+                              Decorate 98 RelaxedPrecision
                               Decorate 99 RelaxedPrecision
                               Decorate 100 RelaxedPrecision
                               Decorate 101 RelaxedPrecision
                               Decorate 102 RelaxedPrecision
-                              Decorate 104 RelaxedPrecision
+                              Decorate 103 RelaxedPrecision
+                              Decorate 105 RelaxedPrecision
+                              Decorate 106 RelaxedPrecision
+                              Decorate 107 RelaxedPrecision
                               Decorate 108 RelaxedPrecision
-                              Decorate 109 RelaxedPrecision
                               Decorate 110 RelaxedPrecision
-                              Decorate 111 RelaxedPrecision
-                              Decorate 113 RelaxedPrecision
                               Decorate 114 RelaxedPrecision
                               Decorate 115 RelaxedPrecision
                               Decorate 116 RelaxedPrecision
+                              Decorate 117 RelaxedPrecision
                               Decorate 119 RelaxedPrecision
-                              Decorate 124 RelaxedPrecision
+                              Decorate 120 RelaxedPrecision
+                              Decorate 121 RelaxedPrecision
+                              Decorate 122 RelaxedPrecision
                               Decorate 125 RelaxedPrecision
-                              Decorate 126 RelaxedPrecision
-                              Decorate 127 RelaxedPrecision
-                              Decorate 129(d) RelaxedPrecision
-                              Decorate 129(d) Flat
                               Decorate 130 RelaxedPrecision
-                              Decorate 134 RelaxedPrecision
-                              Decorate 135 RelaxedPrecision
+                              Decorate 131 RelaxedPrecision
+                              Decorate 132 RelaxedPrecision
+                              Decorate 133 RelaxedPrecision
+                              Decorate 135(d) RelaxedPrecision
+                              Decorate 135(d) Flat
                               Decorate 136 RelaxedPrecision
-                              Decorate 137 RelaxedPrecision
-                              Decorate 138 RelaxedPrecision
-                              Decorate 139 RelaxedPrecision
                               Decorate 140 RelaxedPrecision
+                              Decorate 141 RelaxedPrecision
                               Decorate 142 RelaxedPrecision
                               Decorate 143 RelaxedPrecision
                               Decorate 144 RelaxedPrecision
                               Decorate 145 RelaxedPrecision
                               Decorate 146 RelaxedPrecision
+                              Decorate 148 RelaxedPrecision
+                              Decorate 149 RelaxedPrecision
                               Decorate 150 RelaxedPrecision
                               Decorate 151 RelaxedPrecision
                               Decorate 152 RelaxedPrecision
-                              Decorate 153 RelaxedPrecision
-                              Decorate 155(i) RelaxedPrecision
-                              Decorate 162 RelaxedPrecision
-                              Decorate 166 RelaxedPrecision
-                              Decorate 171 RelaxedPrecision
+                              Decorate 156 RelaxedPrecision
+                              Decorate 157 RelaxedPrecision
+                              Decorate 158 RelaxedPrecision
+                              Decorate 159 RelaxedPrecision
+                              Decorate 161(i) RelaxedPrecision
+                              Decorate 168 RelaxedPrecision
                               Decorate 172 RelaxedPrecision
-                              Decorate 173 RelaxedPrecision
-                              Decorate 174 RelaxedPrecision
-                              Decorate 175(j) RelaxedPrecision
-                              Decorate 182 RelaxedPrecision
-                              Decorate 185 RelaxedPrecision
-                              Decorate 186 RelaxedPrecision
-                              Decorate 187 RelaxedPrecision
+                              Decorate 177 RelaxedPrecision
+                              Decorate 178 RelaxedPrecision
+                              Decorate 179 RelaxedPrecision
+                              Decorate 180 RelaxedPrecision
+                              Decorate 181(j) RelaxedPrecision
+                              Decorate 188 RelaxedPrecision
+                              Decorate 191 RelaxedPrecision
+                              Decorate 192 RelaxedPrecision
                               Decorate 193 RelaxedPrecision
-                              Decorate 194 RelaxedPrecision
-                              Decorate 196 RelaxedPrecision
-                              Decorate 197 RelaxedPrecision
-                              Decorate 198 RelaxedPrecision
                               Decorate 199 RelaxedPrecision
+                              Decorate 200 RelaxedPrecision
                               Decorate 202 RelaxedPrecision
                               Decorate 203 RelaxedPrecision
                               Decorate 204 RelaxedPrecision
                               Decorate 205 RelaxedPrecision
-                              Decorate 207 RelaxedPrecision
+                              Decorate 208 RelaxedPrecision
+                              Decorate 209 RelaxedPrecision
+                              Decorate 210 RelaxedPrecision
+                              Decorate 211 RelaxedPrecision
                               Decorate 213 RelaxedPrecision
-                              Decorate 214 RelaxedPrecision
-                              Decorate 215 RelaxedPrecision
                               Decorate 219 RelaxedPrecision
                               Decorate 220 RelaxedPrecision
                               Decorate 221 RelaxedPrecision
-                              Decorate 222 RelaxedPrecision
-                              Decorate 227(color) RelaxedPrecision
+                              Decorate 225 RelaxedPrecision
+                              Decorate 226 RelaxedPrecision
+                              Decorate 227 RelaxedPrecision
                               Decorate 228 RelaxedPrecision
-                              Decorate 229 RelaxedPrecision
-                              Decorate 230 RelaxedPrecision
-                              Decorate 231 RelaxedPrecision
-                              Decorate 233(v) RelaxedPrecision
-                              Decorate 234(param) RelaxedPrecision
+                              Decorate 233(color) RelaxedPrecision
+                              Decorate 234 RelaxedPrecision
                               Decorate 235 RelaxedPrecision
-                              Decorate 236(param) RelaxedPrecision
+                              Decorate 236 RelaxedPrecision
                               Decorate 237 RelaxedPrecision
-                              Decorate 238(param) RelaxedPrecision
-                              Decorate 239 RelaxedPrecision
-                              Decorate 240 RelaxedPrecision
+                              Decorate 239(v) RelaxedPrecision
+                              Decorate 240(param) RelaxedPrecision
+                              Decorate 241 RelaxedPrecision
+                              Decorate 242(param) RelaxedPrecision
                               Decorate 243 RelaxedPrecision
-                              Decorate 244 RelaxedPrecision
+                              Decorate 244(param) RelaxedPrecision
                               Decorate 245 RelaxedPrecision
-                              Decorate 246(param) RelaxedPrecision
-                              Decorate 247 RelaxedPrecision
-                              Decorate 248(param) RelaxedPrecision
+                              Decorate 246 RelaxedPrecision
                               Decorate 249 RelaxedPrecision
-                              Decorate 250(param) RelaxedPrecision
+                              Decorate 250 RelaxedPrecision
                               Decorate 251 RelaxedPrecision
-                              Decorate 252 RelaxedPrecision
-                              Decorate 254 RelaxedPrecision
+                              Decorate 252(param) RelaxedPrecision
+                              Decorate 253 RelaxedPrecision
+                              Decorate 254(param) RelaxedPrecision
                               Decorate 255 RelaxedPrecision
-                              Decorate 256 RelaxedPrecision
+                              Decorate 256(param) RelaxedPrecision
                               Decorate 257 RelaxedPrecision
-                              Decorate 264 RelaxedPrecision
+                              Decorate 258 RelaxedPrecision
+                              Decorate 260 RelaxedPrecision
+                              Decorate 261 RelaxedPrecision
+                              Decorate 262 RelaxedPrecision
+                              Decorate 263 RelaxedPrecision
+                              Decorate 270 RelaxedPrecision
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
@@ -186,295 +192,295 @@
               11:             TypeFunction 7(fvec4) 8(ptr) 8(ptr) 10(ptr)
               36:    6(float) Constant 0
               37:    7(fvec4) ConstantComposite 36 36 36 36
-              48:    6(float) Constant 1065353216
-              49:    7(fvec4) ConstantComposite 48 48 48 48
-              61:             TypePointer Input 9(int)
-           62(c):     61(ptr) Variable Input
-              65:      9(int) Constant 1
-              72:             TypePointer Function 6(float)
-              74:             TypePointer Input 6(float)
-           75(x):     74(ptr) Variable Input
-          129(d):     61(ptr) Variable Input
-             156:      9(int) Constant 0
-             163:      9(int) Constant 10
-             164:             TypeBool
-             176:      9(int) Constant 20
-             183:      9(int) Constant 30
-             188:    6(float) Constant 1120429670
-             208:    6(float) Constant 1079739679
-             226:             TypePointer Output 6(float)
-      227(color):    226(ptr) Variable Output
-             232:             TypePointer Input 7(fvec4)
-          233(v):    232(ptr) Variable Input
-             241:             TypeInt 32 0
-             242:    241(int) Constant 1
-             253:    241(int) Constant 2
+              50:    6(float) Constant 1065353216
+              51:    7(fvec4) ConstantComposite 50 50 50 50
+              67:             TypePointer Input 9(int)
+           68(c):     67(ptr) Variable Input
+              71:      9(int) Constant 1
+              78:             TypePointer Function 6(float)
+              80:             TypePointer Input 6(float)
+           81(x):     80(ptr) Variable Input
+          135(d):     67(ptr) Variable Input
+             162:      9(int) Constant 0
+             169:      9(int) Constant 10
+             170:             TypeBool
+             182:      9(int) Constant 20
+             189:      9(int) Constant 30
+             194:    6(float) Constant 1120429670
+             214:    6(float) Constant 1079739679
+             232:             TypePointer Output 6(float)
+      233(color):    232(ptr) Variable Output
+             238:             TypePointer Input 7(fvec4)
+          239(v):    238(ptr) Variable Input
+             247:             TypeInt 32 0
+             248:    247(int) Constant 1
+             259:    247(int) Constant 2
          4(main):           2 Function None 3
                5:             Label
-       60(local):     10(ptr) Variable Function
-           73(f):     72(ptr) Variable Function
-          155(i):     10(ptr) Variable Function
-          175(j):     10(ptr) Variable Function
-      234(param):      8(ptr) Variable Function
-      236(param):      8(ptr) Variable Function
-      238(param):     10(ptr) Variable Function
-      246(param):      8(ptr) Variable Function
-      248(param):      8(ptr) Variable Function
-      250(param):     10(ptr) Variable Function
-              63:      9(int) Load 62(c)
-                              Store 60(local) 63
-              64:      9(int) Load 60(local)
-              66:      9(int) IAdd 64 65
-                              Store 60(local) 66
-              67:      9(int) Load 62(c)
-                              SelectionMerge 71 None
-                              Switch 67 70 
-                                     case 1: 68
-                                     case 2: 69
-              70:               Label
-              82:    6(float)   Load 75(x)
-              83:    6(float)   ExtInst 1(GLSL.std.450) 15(Tan) 82
-                                Store 73(f) 83
-                                Branch 71
-              68:               Label
-              76:    6(float)   Load 75(x)
-              77:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 76
-                                Store 73(f) 77
-                                Branch 71
-              69:               Label
-              79:    6(float)   Load 75(x)
-              80:    6(float)   ExtInst 1(GLSL.std.450) 14(Cos) 79
-                                Store 73(f) 80
-                                Branch 71
-              71:             Label
-              85:      9(int) Load 62(c)
-                              SelectionMerge 89 None
-                              Switch 85 88 
-                                     case 1: 86
-                                     case 2: 87
-              88:               Label
-              99:    6(float)   Load 75(x)
-             100:    6(float)   ExtInst 1(GLSL.std.450) 15(Tan) 99
-             101:    6(float)   Load 73(f)
-             102:    6(float)   FAdd 101 100
-                                Store 73(f) 102
-                                Branch 89
-              86:               Label
-              90:    6(float)   Load 75(x)
-              91:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 90
-              92:    6(float)   Load 73(f)
-              93:    6(float)   FAdd 92 91
-                                Store 73(f) 93
-                                Branch 87
-              87:               Label
-              94:    6(float)   Load 75(x)
-              95:    6(float)   ExtInst 1(GLSL.std.450) 14(Cos) 94
-              96:    6(float)   Load 73(f)
-              97:    6(float)   FAdd 96 95
-                                Store 73(f) 97
-                                Branch 89
-              89:             Label
-             104:      9(int) Load 62(c)
-                              SelectionMerge 107 None
-                              Switch 104 107 
-                                     case 1: 105
-                                     case 2: 106
-             105:               Label
-             108:    6(float)   Load 75(x)
-             109:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 108
-             110:    6(float)   Load 73(f)
-             111:    6(float)   FAdd 110 109
-                                Store 73(f) 111
-                                Branch 107
-             106:               Label
-             113:    6(float)   Load 75(x)
-             114:    6(float)   ExtInst 1(GLSL.std.450) 14(Cos) 113
-             115:    6(float)   Load 73(f)
-             116:    6(float)   FAdd 115 114
-                                Store 73(f) 116
-                                Branch 107
-             107:             Label
-             119:      9(int) Load 62(c)
-                              SelectionMerge 123 None
-                              Switch 119 122 
-                                     case 1: 120
-                                     case 2: 121
-             122:               Label
-             150:    6(float)   Load 75(x)
-             151:    6(float)   ExtInst 1(GLSL.std.450) 15(Tan) 150
-             152:    6(float)   Load 73(f)
-             153:    6(float)   FAdd 152 151
-                                Store 73(f) 153
-                                Branch 123
-             120:               Label
-             124:    6(float)   Load 75(x)
-             125:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 124
-             126:    6(float)   Load 73(f)
-             127:    6(float)   FAdd 126 125
-                                Store 73(f) 127
-                                Branch 123
-             121:               Label
-             130:      9(int)   Load 129(d)
-                                SelectionMerge 133 None
-                                Switch 130 133 
-                                       case 1: 131
-                                       case 2: 132
-             131:                 Label
-             134:    6(float)     Load 75(x)
-             135:    6(float)     Load 75(x)
-             136:    6(float)     FMul 134 135
-             137:    6(float)     Load 75(x)
-             138:    6(float)     FMul 136 137
-             139:    6(float)     Load 73(f)
-             140:    6(float)     FAdd 139 138
-                                  Store 73(f) 140
-                                  Branch 133
-             132:                 Label
-             142:    6(float)     Load 75(x)
-             143:    6(float)     Load 75(x)
+       66(local):     10(ptr) Variable Function
+           79(f):     78(ptr) Variable Function
+          161(i):     10(ptr) Variable Function
+          181(j):     10(ptr) Variable Function
+      240(param):      8(ptr) Variable Function
+      242(param):      8(ptr) Variable Function
+      244(param):     10(ptr) Variable Function
+      252(param):      8(ptr) Variable Function
+      254(param):      8(ptr) Variable Function
+      256(param):     10(ptr) Variable Function
+              69:      9(int) Load 68(c)
+                              Store 66(local) 69
+              70:      9(int) Load 66(local)
+              72:      9(int) IAdd 70 71
+                              Store 66(local) 72
+              73:      9(int) Load 68(c)
+                              SelectionMerge 77 None
+                              Switch 73 76 
+                                     case 1: 74
+                                     case 2: 75
+              76:               Label
+              88:    6(float)   Load 81(x)
+              89:    6(float)   ExtInst 1(GLSL.std.450) 15(Tan) 88
+                                Store 79(f) 89
+                                Branch 77
+              74:               Label
+              82:    6(float)   Load 81(x)
+              83:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 82
+                                Store 79(f) 83
+                                Branch 77
+              75:               Label
+              85:    6(float)   Load 81(x)
+              86:    6(float)   ExtInst 1(GLSL.std.450) 14(Cos) 85
+                                Store 79(f) 86
+                                Branch 77
+              77:             Label
+              91:      9(int) Load 68(c)
+                              SelectionMerge 95 None
+                              Switch 91 94 
+                                     case 1: 92
+                                     case 2: 93
+              94:               Label
+             105:    6(float)   Load 81(x)
+             106:    6(float)   ExtInst 1(GLSL.std.450) 15(Tan) 105
+             107:    6(float)   Load 79(f)
+             108:    6(float)   FAdd 107 106
+                                Store 79(f) 108
+                                Branch 95
+              92:               Label
+              96:    6(float)   Load 81(x)
+              97:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 96
+              98:    6(float)   Load 79(f)
+              99:    6(float)   FAdd 98 97
+                                Store 79(f) 99
+                                Branch 93
+              93:               Label
+             100:    6(float)   Load 81(x)
+             101:    6(float)   ExtInst 1(GLSL.std.450) 14(Cos) 100
+             102:    6(float)   Load 79(f)
+             103:    6(float)   FAdd 102 101
+                                Store 79(f) 103
+                                Branch 95
+              95:             Label
+             110:      9(int) Load 68(c)
+                              SelectionMerge 113 None
+                              Switch 110 113 
+                                     case 1: 111
+                                     case 2: 112
+             111:               Label
+             114:    6(float)   Load 81(x)
+             115:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 114
+             116:    6(float)   Load 79(f)
+             117:    6(float)   FAdd 116 115
+                                Store 79(f) 117
+                                Branch 113
+             112:               Label
+             119:    6(float)   Load 81(x)
+             120:    6(float)   ExtInst 1(GLSL.std.450) 14(Cos) 119
+             121:    6(float)   Load 79(f)
+             122:    6(float)   FAdd 121 120
+                                Store 79(f) 122
+                                Branch 113
+             113:             Label
+             125:      9(int) Load 68(c)
+                              SelectionMerge 129 None
+                              Switch 125 128 
+                                     case 1: 126
+                                     case 2: 127
+             128:               Label
+             156:    6(float)   Load 81(x)
+             157:    6(float)   ExtInst 1(GLSL.std.450) 15(Tan) 156
+             158:    6(float)   Load 79(f)
+             159:    6(float)   FAdd 158 157
+                                Store 79(f) 159
+                                Branch 129
+             126:               Label
+             130:    6(float)   Load 81(x)
+             131:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 130
+             132:    6(float)   Load 79(f)
+             133:    6(float)   FAdd 132 131
+                                Store 79(f) 133
+                                Branch 129
+             127:               Label
+             136:      9(int)   Load 135(d)
+                                SelectionMerge 139 None
+                                Switch 136 139 
+                                       case 1: 137
+                                       case 2: 138
+             137:                 Label
+             140:    6(float)     Load 81(x)
+             141:    6(float)     Load 81(x)
+             142:    6(float)     FMul 140 141
+             143:    6(float)     Load 81(x)
              144:    6(float)     FMul 142 143
-             145:    6(float)     Load 73(f)
+             145:    6(float)     Load 79(f)
              146:    6(float)     FAdd 145 144
-                                  Store 73(f) 146
-                                  Branch 133
-             133:               Label
-                                Branch 123
-             123:             Label
-                              Store 155(i) 156
-                              Branch 157
-             157:             Label
-                              LoopMerge 159 160 None
-                              Branch 161
-             161:             Label
-             162:      9(int) Load 155(i)
-             165:   164(bool) SLessThan 162 163
-                              BranchConditional 165 158 159
-             158:               Label
-             166:      9(int)   Load 62(c)
-                                SelectionMerge 170 None
-                                Switch 166 169 
-                                       case 1: 167
-                                       case 2: 168
-             169:                 Label
-             202:    6(float)     Load 75(x)
-             203:    6(float)     ExtInst 1(GLSL.std.450) 15(Tan) 202
-             204:    6(float)     Load 73(f)
+                                  Store 79(f) 146
+                                  Branch 139
+             138:                 Label
+             148:    6(float)     Load 81(x)
+             149:    6(float)     Load 81(x)
+             150:    6(float)     FMul 148 149
+             151:    6(float)     Load 79(f)
+             152:    6(float)     FAdd 151 150
+                                  Store 79(f) 152
+                                  Branch 139
+             139:               Label
+                                Branch 129
+             129:             Label
+                              Store 161(i) 162
+                              Branch 163
+             163:             Label
+                              LoopMerge 165 166 None
+                              Branch 167
+             167:             Label
+             168:      9(int) Load 161(i)
+             171:   170(bool) SLessThan 168 169
+                              BranchConditional 171 164 165
+             164:               Label
+             172:      9(int)   Load 68(c)
+                                SelectionMerge 176 None
+                                Switch 172 175 
+                                       case 1: 173
+                                       case 2: 174
+             175:                 Label
+             208:    6(float)     Load 81(x)
+             209:    6(float)     ExtInst 1(GLSL.std.450) 15(Tan) 208
+             210:    6(float)     Load 79(f)
+             211:    6(float)     FAdd 210 209
+                                  Store 79(f) 211
+                                  Branch 176
+             173:                 Label
+             177:    6(float)     Load 81(x)
+             178:    6(float)     ExtInst 1(GLSL.std.450) 13(Sin) 177
+             179:    6(float)     Load 79(f)
+             180:    6(float)     FAdd 179 178
+                                  Store 79(f) 180
+                                  Store 181(j) 182
+                                  Branch 183
+             183:                 Label
+                                  LoopMerge 185 186 None
+                                  Branch 187
+             187:                 Label
+             188:      9(int)     Load 181(j)
+             190:   170(bool)     SLessThan 188 189
+                                  BranchConditional 190 184 185
+             184:                   Label
+             191:    6(float)       Load 79(f)
+             192:    6(float)       FAdd 191 50
+                                    Store 79(f) 192
+             193:    6(float)       Load 79(f)
+             195:   170(bool)       FOrdLessThan 193 194
+                                    SelectionMerge 197 None
+                                    BranchConditional 195 196 197
+             196:                     Label
+                                      Branch 185
+             197:                   Label
+                                    Branch 186
+             186:                   Label
+             199:      9(int)       Load 181(j)
+             200:      9(int)       IAdd 199 71
+                                    Store 181(j) 200
+                                    Branch 183
+             185:                 Label
+                                  Branch 176
+             174:                 Label
+             202:    6(float)     Load 81(x)
+             203:    6(float)     ExtInst 1(GLSL.std.450) 14(Cos) 202
+             204:    6(float)     Load 79(f)
              205:    6(float)     FAdd 204 203
-                                  Store 73(f) 205
-                                  Branch 170
-             167:                 Label
-             171:    6(float)     Load 75(x)
-             172:    6(float)     ExtInst 1(GLSL.std.450) 13(Sin) 171
-             173:    6(float)     Load 73(f)
-             174:    6(float)     FAdd 173 172
-                                  Store 73(f) 174
-                                  Store 175(j) 176
-                                  Branch 177
-             177:                 Label
-                                  LoopMerge 179 180 None
-                                  Branch 181
-             181:                 Label
-             182:      9(int)     Load 175(j)
-             184:   164(bool)     SLessThan 182 183
-                                  BranchConditional 184 178 179
-             178:                   Label
-             185:    6(float)       Load 73(f)
-             186:    6(float)       FAdd 185 48
-                                    Store 73(f) 186
-             187:    6(float)       Load 73(f)
-             189:   164(bool)       FOrdLessThan 187 188
-                                    SelectionMerge 191 None
-                                    BranchConditional 189 190 191
-             190:                     Label
-                                      Branch 179
-             191:                   Label
-                                    Branch 180
-             180:                   Label
-             193:      9(int)       Load 175(j)
-             194:      9(int)       IAdd 193 65
-                                    Store 175(j) 194
-                                    Branch 177
-             179:                 Label
-                                  Branch 170
-             168:                 Label
-             196:    6(float)     Load 75(x)
-             197:    6(float)     ExtInst 1(GLSL.std.450) 14(Cos) 196
-             198:    6(float)     Load 73(f)
-             199:    6(float)     FAdd 198 197
-                                  Store 73(f) 199
-                                  Branch 170
-             170:               Label
-             207:    6(float)   Load 73(f)
-             209:   164(bool)   FOrdLessThan 207 208
-                                SelectionMerge 211 None
-                                BranchConditional 209 210 211
-             210:                 Label
-                                  Branch 159
-             211:               Label
-                                Branch 160
-             160:               Label
-             213:      9(int)   Load 155(i)
-             214:      9(int)   IAdd 213 65
-                                Store 155(i) 214
-                                Branch 157
-             159:             Label
-             215:      9(int) Load 62(c)
-                              SelectionMerge 218 None
-                              Switch 215 218 
-                                     case 1: 216
-                                     case 2: 217
-             216:               Label
-             219:    6(float)   Load 75(x)
-             220:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 219
-             221:    6(float)   Load 73(f)
-             222:    6(float)   FAdd 221 220
-                                Store 73(f) 222
-                                Branch 218
+                                  Store 79(f) 205
+                                  Branch 176
+             176:               Label
+             213:    6(float)   Load 79(f)
+             215:   170(bool)   FOrdLessThan 213 214
+                                SelectionMerge 217 None
+                                BranchConditional 215 216 217
+             216:                 Label
+                                  Branch 165
              217:               Label
-                                Branch 218
-             218:             Label
-             228:    6(float) Load 73(f)
-             229:      9(int) Load 60(local)
-             230:    6(float) ConvertSToF 229
-             231:    6(float) FAdd 228 230
-                              Store 227(color) 231
-             235:    7(fvec4) Load 233(v)
-                              Store 234(param) 235
-             237:    7(fvec4) Load 233(v)
-                              Store 236(param) 237
-             239:      9(int) Load 62(c)
-                              Store 238(param) 239
-             240:    7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 234(param) 236(param) 238(param)
-             243:    6(float) CompositeExtract 240 1
-             244:    6(float) Load 227(color)
-             245:    6(float) FAdd 244 243
-                              Store 227(color) 245
-             247:    7(fvec4) Load 233(v)
-                              Store 246(param) 247
-             249:    7(fvec4) Load 233(v)
-                              Store 248(param) 249
-             251:      9(int) Load 62(c)
-                              Store 250(param) 251
-             252:    7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 246(param) 248(param) 250(param)
-             254:    6(float) CompositeExtract 252 2
-             255:    6(float) Load 227(color)
-             256:    6(float) FAdd 255 254
-                              Store 227(color) 256
-             257:      9(int) Load 62(c)
-                              SelectionMerge 260 None
-                              Switch 257 259 
-                                     case 0: 258
-             259:               Label
-                                Branch 260
-             258:               Label
-                                Branch 260
-             260:             Label
-             264:      9(int) Load 62(c)
+                                Branch 166
+             166:               Label
+             219:      9(int)   Load 161(i)
+             220:      9(int)   IAdd 219 71
+                                Store 161(i) 220
+                                Branch 163
+             165:             Label
+             221:      9(int) Load 68(c)
+                              SelectionMerge 224 None
+                              Switch 221 224 
+                                     case 1: 222
+                                     case 2: 223
+             222:               Label
+             225:    6(float)   Load 81(x)
+             226:    6(float)   ExtInst 1(GLSL.std.450) 13(Sin) 225
+             227:    6(float)   Load 79(f)
+             228:    6(float)   FAdd 227 226
+                                Store 79(f) 228
+                                Branch 224
+             223:               Label
+                                Branch 224
+             224:             Label
+             234:    6(float) Load 79(f)
+             235:      9(int) Load 66(local)
+             236:    6(float) ConvertSToF 235
+             237:    6(float) FAdd 234 236
+                              Store 233(color) 237
+             241:    7(fvec4) Load 239(v)
+                              Store 240(param) 241
+             243:    7(fvec4) Load 239(v)
+                              Store 242(param) 243
+             245:      9(int) Load 68(c)
+                              Store 244(param) 245
+             246:    7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 240(param) 242(param) 244(param)
+             249:    6(float) CompositeExtract 246 1
+             250:    6(float) Load 233(color)
+             251:    6(float) FAdd 250 249
+                              Store 233(color) 251
+             253:    7(fvec4) Load 239(v)
+                              Store 252(param) 253
+             255:    7(fvec4) Load 239(v)
+                              Store 254(param) 255
+             257:      9(int) Load 68(c)
+                              Store 256(param) 257
+             258:    7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 252(param) 254(param) 256(param)
+             260:    6(float) CompositeExtract 258 2
+             261:    6(float) Load 233(color)
+             262:    6(float) FAdd 261 260
+                              Store 233(color) 262
+             263:      9(int) Load 68(c)
                               SelectionMerge 266 None
-                              Switch 264 265
+                              Switch 263 265 
+                                     case 0: 264
              265:               Label
                                 Branch 266
+             264:               Label
+                                Branch 266
              266:             Label
+             270:      9(int) Load 68(c)
+                              SelectionMerge 272 None
+                              Switch 270 271
+             271:               Label
+                                Branch 272
+             272:             Label
                               Return
                               FunctionEnd
 15(foo1(vf4;vf4;i1;):    7(fvec4) Function None 11
@@ -482,6 +488,7 @@
           13(v2):      8(ptr) FunctionParameter
           14(i1):     10(ptr) FunctionParameter
               16:             Label
+              38:      8(ptr) Variable Function
               22:      9(int) Load 14(i1)
                               SelectionMerge 26 None
                               Switch 22 26 
@@ -501,33 +508,41 @@
               33:    7(fvec4)   FMul 31 32
                                 ReturnValue 33
               26:             Label
-                              ReturnValue 37
+                              Store 38 37
+              39:    7(fvec4) Load 38
+                              ReturnValue 39
                               FunctionEnd
 20(foo2(vf4;vf4;i1;):    7(fvec4) Function None 11
           17(v1):      8(ptr) FunctionParameter
           18(v2):      8(ptr) FunctionParameter
           19(i1):     10(ptr) FunctionParameter
               21:             Label
-              40:      9(int) Load 19(i1)
-                              SelectionMerge 45 None
-                              Switch 40 45 
-                                     case 0: 41
-                                     case 2: 42
-                                     case 1: 43
-                                     case 3: 44
-              41:               Label
-              46:    7(fvec4)   Load 17(v1)
-                                ReturnValue 46
-              42:               Label
-                                ReturnValue 49
+              52:      8(ptr) Variable Function
+              62:      8(ptr) Variable Function
+              42:      9(int) Load 19(i1)
+                              SelectionMerge 47 None
+                              Switch 42 47 
+                                     case 0: 43
+                                     case 2: 44
+                                     case 1: 45
+                                     case 3: 46
               43:               Label
-              51:    7(fvec4)   Load 18(v2)
-                                ReturnValue 51
+              48:    7(fvec4)   Load 17(v1)
+                                ReturnValue 48
               44:               Label
-              53:    7(fvec4)   Load 17(v1)
-              54:    7(fvec4)   Load 18(v2)
-              55:    7(fvec4)   FMul 53 54
+                                Store 52 51
+              53:    7(fvec4)   Load 52
+                                ReturnValue 53
+              45:               Label
+              55:    7(fvec4)   Load 18(v2)
                                 ReturnValue 55
-              45:             Label
-                              ReturnValue 37
+              46:               Label
+              57:    7(fvec4)   Load 17(v1)
+              58:    7(fvec4)   Load 18(v2)
+              59:    7(fvec4)   FMul 57 58
+                                ReturnValue 59
+              47:             Label
+                              Store 62 37
+              63:    7(fvec4) Load 62
+                              ReturnValue 63
                               FunctionEnd
diff --git a/Test/spv.precision.frag b/Test/spv.precision.frag
index 090c1a6..463afdf 100644
--- a/Test/spv.precision.frag
+++ b/Test/spv.precision.frag
@@ -57,4 +57,6 @@
     

     mediumfout *= s.a;

     mediumfout *= s.b;

+

+    mediumfout = ((mediumfin * mediumfin > 4.2) ? 2.0 * mediumfout : 3.0 * mediumfout);

 }

diff --git a/Test/spv.precisionArgs.frag b/Test/spv.precisionArgs.frag
index 24be1d0..4a968cb 100644
--- a/Test/spv.precisionArgs.frag
+++ b/Test/spv.precisionArgs.frag
@@ -6,6 +6,11 @@
 
 void foo(in float f, in highp float g) { }
 
+      float retM (      float x) { return x; }
+highp float retH (highp float x) { return x; }
+      float retHM(highp float x) { return x; }
+highp float retMH(      float x) { return x; }
+
 void main()
 {
     float aM, bM;
@@ -14,4 +19,9 @@
     fooConst(aH, bH);   // must copy aH
     foo(aM, bM);
     foo(aH, bH);
+
+    retM(aM);
+    retH(aH);
+    retHM(aH);
+    retMH(aM);
 }