SPIR-V: Aggressively prune unreachable merge, continue target
More aggressively prune unreachable code as follows.
When no control flow edges reach a merge block or continue target:
- delete their contents so that:
- a merge block becomes OpLabel, then OpUnreachable
- a continue target becomes OpLabel, then an OpBranch back to the
loop header
- any basic block which is dominated by such a merge block or continue
target is removed as well.
- decorations targeting the removed instructions are removed.
Enables the SPIR-V builder post-processing step the GLSLANG_WEB case.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 99c4c3f..df42458 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -1630,11 +1630,11 @@
for (auto it = iOSet.cbegin(); it != iOSet.cend(); ++it)
entryPoint->addIdOperand(*it);
-#ifndef GLSLANG_WEB
- // Add capabilities, extensions, remove unneeded decorations, etc.,
+ // Add capabilities, extensions, remove unneeded decorations, etc.,
// based on the resulting SPIR-V.
+ // Note: WebGPU code generation must have the opportunity to aggressively
+ // prune unreachable merge blocks and continue targets.
builder.postProcess();
-#endif
}
// Write the SPV into 'out'.
diff --git a/SPIRV/InReadableOrder.cpp b/SPIRV/InReadableOrder.cpp
index 52b2961..9d9410b 100644
--- a/SPIRV/InReadableOrder.cpp
+++ b/SPIRV/InReadableOrder.cpp
@@ -61,17 +61,22 @@
// Use by calling visit() on the root block.
class ReadableOrderTraverser {
public:
- explicit ReadableOrderTraverser(std::function<void(Block*)> callback) : callback_(callback) {}
+ ReadableOrderTraverser(std::function<void(Block*, spv::ReachReason, Block*)> callback)
+ : callback_(callback) {}
// Visits the block if it hasn't been visited already and isn't currently
- // being delayed. Invokes callback(block), then descends into its
+ // being delayed. Invokes callback(block, why, header), then descends into its
// successors. Delays merge-block and continue-block processing until all
- // the branches have been completed.
- void visit(Block* block)
+ // the branches have been completed. If |block| is an unreachable merge block or
+ // an unreachable continue target, then |header| is the corresponding header block.
+ void visit(Block* block, spv::ReachReason why, Block* header)
{
assert(block);
+ if (why == spv::ReachViaControlFlow) {
+ reachableViaControlFlow_.insert(block);
+ }
if (visited_.count(block) || delayed_.count(block))
return;
- callback_(block);
+ callback_(block, why, header);
visited_.insert(block);
Block* mergeBlock = nullptr;
Block* continueBlock = nullptr;
@@ -87,27 +92,40 @@
delayed_.insert(continueBlock);
}
}
- const auto successors = block->getSuccessors();
- for (auto it = successors.cbegin(); it != successors.cend(); ++it)
- visit(*it);
+ if (why == spv::ReachViaControlFlow) {
+ const auto& successors = block->getSuccessors();
+ for (auto it = successors.cbegin(); it != successors.cend(); ++it)
+ visit(*it, why, nullptr);
+ }
if (continueBlock) {
+ const spv::ReachReason continueWhy =
+ (reachableViaControlFlow_.count(continueBlock) > 0)
+ ? spv::ReachViaControlFlow
+ : spv::ReachDeadContinue;
delayed_.erase(continueBlock);
- visit(continueBlock);
+ visit(continueBlock, continueWhy, block);
}
if (mergeBlock) {
+ const spv::ReachReason mergeWhy =
+ (reachableViaControlFlow_.count(mergeBlock) > 0)
+ ? spv::ReachViaControlFlow
+ : spv::ReachDeadMerge;
delayed_.erase(mergeBlock);
- visit(mergeBlock);
+ visit(mergeBlock, mergeWhy, block);
}
}
private:
- std::function<void(Block*)> callback_;
+ std::function<void(Block*, spv::ReachReason, Block*)> callback_;
// Whether a block has already been visited or is being delayed.
std::unordered_set<Block *> visited_, delayed_;
+
+ // The set of blocks that actually are reached via control flow.
+ std::unordered_set<Block *> reachableViaControlFlow_;
};
}
-void spv::inReadableOrder(Block* root, std::function<void(Block*)> callback)
+void spv::inReadableOrder(Block* root, std::function<void(Block*, spv::ReachReason, Block*)> callback)
{
- ReadableOrderTraverser(callback).visit(root);
+ ReadableOrderTraverser(callback).visit(root, spv::ReachViaControlFlow, nullptr);
}
diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h
index 55754f6..8d8f34b 100644
--- a/SPIRV/SpvBuilder.h
+++ b/SPIRV/SpvBuilder.h
@@ -683,14 +683,12 @@
// based on the type of the base and the chain of dereferences.
Id accessChainGetInferredType();
- // Add capabilities, extensions, remove unneeded decorations, etc.,
+ // Add capabilities, extensions, remove unneeded decorations, etc.,
// based on the resulting SPIR-V.
void postProcess();
// Hook to visit each instruction in a block in a function
void postProcess(Instruction&);
- // Hook to visit each instruction in a reachable block in a function.
- void postProcessReachable(const Instruction&);
// Hook to visit each non-32-bit sized float/int operation in a block.
void postProcessType(const Instruction&, spv::Id typeId);
diff --git a/SPIRV/SpvPostProcess.cpp b/SPIRV/SpvPostProcess.cpp
index 832ee3e..86fad58 100644
--- a/SPIRV/SpvPostProcess.cpp
+++ b/SPIRV/SpvPostProcess.cpp
@@ -39,6 +39,7 @@
#include <cassert>
#include <cstdlib>
+#include <unordered_map>
#include <unordered_set>
#include <algorithm>
@@ -319,16 +320,14 @@
}
}
-// Called for each instruction in a reachable block.
-void Builder::postProcessReachable(const Instruction&)
-{
- // did have code here, but questionable to do so without deleting the instructions
-}
-
// comment in header
void Builder::postProcess()
{
+ // reachableBlocks is the set of blockss reached via control flow, or which are
+ // unreachable continue targert or unreachable merge.
std::unordered_set<const Block*> reachableBlocks;
+ std::unordered_map<Block*, Block*> headerForUnreachableContinue;
+ std::unordered_set<Block*> unreachableMerges;
std::unordered_set<Id> unreachableDefinitions;
// Collect IDs defined in unreachable blocks. For each function, label the
// reachable blocks first. Then for each unreachable block, collect the
@@ -336,16 +335,41 @@
for (auto fi = module.getFunctions().cbegin(); fi != module.getFunctions().cend(); fi++) {
Function* f = *fi;
Block* entry = f->getEntryBlock();
- inReadableOrder(entry, [&reachableBlocks](const Block* b) { reachableBlocks.insert(b); });
+ inReadableOrder(entry,
+ [&reachableBlocks, &unreachableMerges, &headerForUnreachableContinue]
+ (Block* b, ReachReason why, Block* header) {
+ reachableBlocks.insert(b);
+ if (why == ReachDeadContinue) headerForUnreachableContinue[b] = header;
+ if (why == ReachDeadMerge) unreachableMerges.insert(b);
+ });
for (auto bi = f->getBlocks().cbegin(); bi != f->getBlocks().cend(); bi++) {
Block* b = *bi;
- if (reachableBlocks.count(b) == 0) {
- for (auto ii = b->getInstructions().cbegin(); ii != b->getInstructions().cend(); ii++)
+ if (unreachableMerges.count(b) != 0 || headerForUnreachableContinue.count(b) != 0) {
+ auto ii = b->getInstructions().cbegin();
+ ++ii; // Keep potential decorations on the label.
+ for (; ii != b->getInstructions().cend(); ++ii)
+ unreachableDefinitions.insert(ii->get()->getResultId());
+ } else if (reachableBlocks.count(b) == 0) {
+ // The normal case for unreachable code. All definitions are considered dead.
+ for (auto ii = b->getInstructions().cbegin(); ii != b->getInstructions().cend(); ++ii)
unreachableDefinitions.insert(ii->get()->getResultId());
}
}
}
+ // Modify unreachable merge blocks and unreachable continue targets.
+ // Delete their contents.
+ for (auto mergeIter = unreachableMerges.begin(); mergeIter != unreachableMerges.end(); ++mergeIter) {
+ (*mergeIter)->rewriteAsCanonicalUnreachableMerge();
+ }
+ for (auto continueIter = headerForUnreachableContinue.begin();
+ continueIter != headerForUnreachableContinue.end();
+ ++continueIter) {
+ Block* continue_target = continueIter->first;
+ Block* header = continueIter->second;
+ continue_target->rewriteAsCanonicalUnreachableContinue(header);
+ }
+
// Remove unneeded decorations, for unreachable instructions
decorations.erase(std::remove_if(decorations.begin(), decorations.end(),
[&unreachableDefinitions](std::unique_ptr<Instruction>& I) -> bool {
@@ -374,13 +398,6 @@
}
}
- // process all reachable instructions...
- for (auto bi = reachableBlocks.cbegin(); bi != reachableBlocks.cend(); ++bi) {
- const Block* block = *bi;
- const auto function = [this](const std::unique_ptr<Instruction>& inst) { postProcessReachable(*inst.get()); };
- std::for_each(block->getInstructions().begin(), block->getInstructions().end(), function);
- }
-
// process all block-contained instructions
for (auto fi = module.getFunctions().cbegin(); fi != module.getFunctions().cend(); fi++) {
Function* f = *fi;
diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h
index 7e2d4bc..9495fce 100755
--- a/SPIRV/spvIR.h
+++ b/SPIRV/spvIR.h
@@ -226,6 +226,36 @@
return nullptr;
}
+ // Change this block into a canonical dead merge block. Delete instructions
+ // as necessary. A canonical dead merge block has only an OpLabel and an
+ // OpUnreachable.
+ void rewriteAsCanonicalUnreachableMerge() {
+ assert(localVariables.empty());
+ // Delete all instructions except for the label.
+ assert(instructions.size() > 0);
+ instructions.resize(1);
+ successors.clear();
+ Instruction* unreachable = new Instruction(OpUnreachable);
+ addInstruction(std::unique_ptr<Instruction>(unreachable));
+ }
+ // Change this block into a canonical dead continue target branching to the
+ // given header ID. Delete instructions as necessary. A canonical dead continue
+ // target has only an OpLabel and an unconditional branch back to the corresponding
+ // header.
+ void rewriteAsCanonicalUnreachableContinue(Block* header) {
+ assert(localVariables.empty());
+ // Delete all instructions except for the label.
+ assert(instructions.size() > 0);
+ instructions.resize(1);
+ successors.clear();
+ // Add OpBranch back to the header.
+ assert(header != nullptr);
+ Instruction* branch = new Instruction(OpBranch);
+ branch->addIdOperand(header->getId());
+ addInstruction(std::move(std::unique_ptr<Instruction>(branch)));
+ successors.push_back(header);
+ }
+
bool isTerminated() const
{
switch (instructions.back()->getOpCode()) {
@@ -235,6 +265,7 @@
case OpKill:
case OpReturn:
case OpReturnValue:
+ case OpUnreachable:
return true;
default:
return false;
@@ -268,10 +299,24 @@
bool unreachable;
};
+// The different reasons for reaching a block in the inReadableOrder traversal.
+typedef enum ReachReason {
+ // Reachable from the entry block via transfers of control, i.e. branches.
+ ReachViaControlFlow = 0,
+ // A continue target that is not reachable via control flow.
+ ReachDeadContinue,
+ // A merge block that is not reachable via control flow.
+ ReachDeadMerge
+};
+
// Traverses the control-flow graph rooted at root in an order suited for
// readable code generation. Invokes callback at every node in the traversal
-// order.
-void inReadableOrder(Block* root, std::function<void(Block*)> callback);
+// order. The callback arguments are:
+// - the block,
+// - the reason we reached the block,
+// - if the reason was that block is an unreachable continue or unreachable merge block
+// then the last parameter is the corresponding header block.
+void inReadableOrder(Block* root, std::function<void(Block*, ReachReason, Block* header)> callback);
//
// SPIR-V IR Function.
@@ -321,7 +366,7 @@
parameterInstructions[p]->dump(out);
// Blocks
- inReadableOrder(blocks[0], [&out](const Block* b) { b->dump(out); });
+ inReadableOrder(blocks[0], [&out](const Block* b, ReachReason, Block*) { b->dump(out); });
Instruction end(0, 0, OpFunctionEnd);
end.dump(out);
}
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index 4be3a4f..0747932 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -988,7 +988,7 @@
// Set base bindings
shader->setShiftBinding(res, baseBinding[res][compUnit.stage]);
-
+
// Set bindings for particular resource sets
// TODO: use a range based for loop here, when available in all environments.
for (auto i = baseBindingForSet[res][compUnit.stage].begin();
diff --git a/Test/baseResults/hlsl.constantbuffer.frag.out b/Test/baseResults/hlsl.constantbuffer.frag.out
index fa8881d..99c67ae 100644
--- a/Test/baseResults/hlsl.constantbuffer.frag.out
+++ b/Test/baseResults/hlsl.constantbuffer.frag.out
@@ -240,6 +240,5 @@
60: 7(fvec4) CompositeConstruct 59 59 59 59
ReturnValue 60
30: Label
- 62: 7(fvec4) Undef
- ReturnValue 62
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/hlsl.doLoop.frag.out b/Test/baseResults/hlsl.doLoop.frag.out
index bb56465..2366d79 100644
--- a/Test/baseResults/hlsl.doLoop.frag.out
+++ b/Test/baseResults/hlsl.doLoop.frag.out
@@ -2,68 +2,95 @@
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
-0:2 Function Definition: @PixelShaderFunction(f1; ( temp 4-component vector of float)
-0:2 Function Parameters:
-0:2 'input' ( in float)
+0:1 Function Definition: f0( ( temp void)
+0:1 Function Parameters:
0:? Sequence
-0:3 Loop with condition not tested first: Unroll
-0:3 Loop Condition
-0:3 Constant:
-0:3 false (const bool)
-0:3 No loop body
-0:4 Loop with condition not tested first: Unroll
-0:4 Loop Condition
-0:4 Constant:
-0:4 false (const bool)
-0:4 No loop body
-0:5 Loop with condition not tested first
-0:5 Loop Condition
-0:5 Compare Greater Than ( temp bool)
-0:5 'input' ( in float)
-0:5 Constant:
-0:5 2.000000
-0:5 Loop Body
-0:? Sequence
-0:5 Branch: Return with expression
-0:5 Construct vec4 ( temp 4-component vector of float)
-0:5 'input' ( in float)
-0:6 Loop with condition not tested first
+0:2 Loop with condition not tested first: Unroll
+0:2 Loop Condition
+0:2 Constant:
+0:2 false (const bool)
+0:2 No loop body
+0:5 Function Definition: f1( ( temp void)
+0:5 Function Parameters:
+0:? Sequence
+0:6 Loop with condition not tested first: Unroll
0:6 Loop Condition
-0:6 Compare Less Than ( temp bool)
-0:6 'input' ( in float)
-0:6 Constant:
-0:6 10.000000
-0:6 Loop Body
-0:6 Pre-Increment ( temp float)
-0:6 'input' ( in float)
-0:7 Loop with condition not tested first
-0:7 Loop Condition
-0:7 Compare Less Than ( temp bool)
-0:7 Pre-Increment ( temp float)
-0:7 'input' ( in float)
-0:7 Constant:
-0:7 10.000000
-0:7 Loop Body
-0:7 Loop with condition tested first
-0:7 Loop Condition
-0:7 Compare Less Than ( temp bool)
-0:7 Pre-Increment ( temp float)
-0:7 'input' ( in float)
-0:7 Constant:
-0:7 10.000000
-0:7 No loop body
-0:8 Branch: Return with expression
-0:8 Construct vec4 ( temp 4-component vector of float)
-0:8 'input' ( in float)
-0:2 Function Definition: PixelShaderFunction( ( temp void)
-0:2 Function Parameters:
+0:6 Constant:
+0:6 false (const bool)
+0:6 No loop body
+0:9 Function Definition: f2(f1; ( temp float)
+0:9 Function Parameters:
+0:9 'input' ( in float)
0:? Sequence
-0:2 move second child to first child ( temp float)
+0:10 Loop with condition not tested first
+0:10 Loop Condition
+0:10 Compare Greater Than ( temp bool)
+0:10 'input' ( in float)
+0:10 Constant:
+0:10 2.000000
+0:10 Loop Body
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 Construct float ( temp float)
+0:10 Construct vec4 ( temp 4-component vector of float)
+0:10 'input' ( in float)
+0:13 Function Definition: f3(f1; ( temp void)
+0:13 Function Parameters:
+0:13 'input' ( in float)
+0:? Sequence
+0:14 Loop with condition not tested first
+0:14 Loop Condition
+0:14 Compare Less Than ( temp bool)
+0:14 'input' ( in float)
+0:14 Constant:
+0:14 10.000000
+0:14 Loop Body
+0:14 Pre-Increment ( temp float)
+0:14 'input' ( in float)
+0:17 Function Definition: f4(f1; ( temp void)
+0:17 Function Parameters:
+0:17 'input' ( in float)
+0:? Sequence
+0:18 Loop with condition not tested first
+0:18 Loop Condition
+0:18 Compare Less Than ( temp bool)
+0:18 Pre-Increment ( temp float)
+0:18 'input' ( in float)
+0:18 Constant:
+0:18 10.000000
+0:18 Loop Body
+0:18 Loop with condition tested first
+0:18 Loop Condition
+0:18 Compare Less Than ( temp bool)
+0:18 Pre-Increment ( temp float)
+0:18 'input' ( in float)
+0:18 Constant:
+0:18 10.000000
+0:18 No loop body
+0:22 Function Definition: @PixelShaderFunction(f1; ( temp 4-component vector of float)
+0:22 Function Parameters:
+0:22 'input' ( in float)
+0:? Sequence
+0:23 Function Call: f0( ( temp void)
+0:24 Function Call: f1( ( temp void)
+0:25 Function Call: f2(f1; ( temp float)
+0:25 'input' ( in float)
+0:26 Function Call: f3(f1; ( temp void)
+0:26 'input' ( in float)
+0:27 Function Call: f4(f1; ( temp void)
+0:27 'input' ( in float)
+0:28 Branch: Return with expression
+0:28 Construct vec4 ( temp 4-component vector of float)
+0:28 'input' ( in float)
+0:22 Function Definition: PixelShaderFunction( ( temp void)
+0:22 Function Parameters:
+0:? Sequence
+0:22 move second child to first child ( temp float)
0:? 'input' ( temp float)
0:? 'input' (layout( location=0) in float)
-0:2 move second child to first child ( temp 4-component vector of float)
+0:22 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
-0:2 Function Call: @PixelShaderFunction(f1; ( temp 4-component vector of float)
+0:22 Function Call: @PixelShaderFunction(f1; ( temp 4-component vector of float)
0:? 'input' ( temp float)
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@@ -76,68 +103,95 @@
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
-0:2 Function Definition: @PixelShaderFunction(f1; ( temp 4-component vector of float)
-0:2 Function Parameters:
-0:2 'input' ( in float)
+0:1 Function Definition: f0( ( temp void)
+0:1 Function Parameters:
0:? Sequence
-0:3 Loop with condition not tested first: Unroll
-0:3 Loop Condition
-0:3 Constant:
-0:3 false (const bool)
-0:3 No loop body
-0:4 Loop with condition not tested first: Unroll
-0:4 Loop Condition
-0:4 Constant:
-0:4 false (const bool)
-0:4 No loop body
-0:5 Loop with condition not tested first
-0:5 Loop Condition
-0:5 Compare Greater Than ( temp bool)
-0:5 'input' ( in float)
-0:5 Constant:
-0:5 2.000000
-0:5 Loop Body
-0:? Sequence
-0:5 Branch: Return with expression
-0:5 Construct vec4 ( temp 4-component vector of float)
-0:5 'input' ( in float)
-0:6 Loop with condition not tested first
+0:2 Loop with condition not tested first: Unroll
+0:2 Loop Condition
+0:2 Constant:
+0:2 false (const bool)
+0:2 No loop body
+0:5 Function Definition: f1( ( temp void)
+0:5 Function Parameters:
+0:? Sequence
+0:6 Loop with condition not tested first: Unroll
0:6 Loop Condition
-0:6 Compare Less Than ( temp bool)
-0:6 'input' ( in float)
-0:6 Constant:
-0:6 10.000000
-0:6 Loop Body
-0:6 Pre-Increment ( temp float)
-0:6 'input' ( in float)
-0:7 Loop with condition not tested first
-0:7 Loop Condition
-0:7 Compare Less Than ( temp bool)
-0:7 Pre-Increment ( temp float)
-0:7 'input' ( in float)
-0:7 Constant:
-0:7 10.000000
-0:7 Loop Body
-0:7 Loop with condition tested first
-0:7 Loop Condition
-0:7 Compare Less Than ( temp bool)
-0:7 Pre-Increment ( temp float)
-0:7 'input' ( in float)
-0:7 Constant:
-0:7 10.000000
-0:7 No loop body
-0:8 Branch: Return with expression
-0:8 Construct vec4 ( temp 4-component vector of float)
-0:8 'input' ( in float)
-0:2 Function Definition: PixelShaderFunction( ( temp void)
-0:2 Function Parameters:
+0:6 Constant:
+0:6 false (const bool)
+0:6 No loop body
+0:9 Function Definition: f2(f1; ( temp float)
+0:9 Function Parameters:
+0:9 'input' ( in float)
0:? Sequence
-0:2 move second child to first child ( temp float)
+0:10 Loop with condition not tested first
+0:10 Loop Condition
+0:10 Compare Greater Than ( temp bool)
+0:10 'input' ( in float)
+0:10 Constant:
+0:10 2.000000
+0:10 Loop Body
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 Construct float ( temp float)
+0:10 Construct vec4 ( temp 4-component vector of float)
+0:10 'input' ( in float)
+0:13 Function Definition: f3(f1; ( temp void)
+0:13 Function Parameters:
+0:13 'input' ( in float)
+0:? Sequence
+0:14 Loop with condition not tested first
+0:14 Loop Condition
+0:14 Compare Less Than ( temp bool)
+0:14 'input' ( in float)
+0:14 Constant:
+0:14 10.000000
+0:14 Loop Body
+0:14 Pre-Increment ( temp float)
+0:14 'input' ( in float)
+0:17 Function Definition: f4(f1; ( temp void)
+0:17 Function Parameters:
+0:17 'input' ( in float)
+0:? Sequence
+0:18 Loop with condition not tested first
+0:18 Loop Condition
+0:18 Compare Less Than ( temp bool)
+0:18 Pre-Increment ( temp float)
+0:18 'input' ( in float)
+0:18 Constant:
+0:18 10.000000
+0:18 Loop Body
+0:18 Loop with condition tested first
+0:18 Loop Condition
+0:18 Compare Less Than ( temp bool)
+0:18 Pre-Increment ( temp float)
+0:18 'input' ( in float)
+0:18 Constant:
+0:18 10.000000
+0:18 No loop body
+0:22 Function Definition: @PixelShaderFunction(f1; ( temp 4-component vector of float)
+0:22 Function Parameters:
+0:22 'input' ( in float)
+0:? Sequence
+0:23 Function Call: f0( ( temp void)
+0:24 Function Call: f1( ( temp void)
+0:25 Function Call: f2(f1; ( temp float)
+0:25 'input' ( in float)
+0:26 Function Call: f3(f1; ( temp void)
+0:26 'input' ( in float)
+0:27 Function Call: f4(f1; ( temp void)
+0:27 'input' ( in float)
+0:28 Branch: Return with expression
+0:28 Construct vec4 ( temp 4-component vector of float)
+0:28 'input' ( in float)
+0:22 Function Definition: PixelShaderFunction( ( temp void)
+0:22 Function Parameters:
+0:? Sequence
+0:22 move second child to first child ( temp float)
0:? 'input' ( temp float)
0:? 'input' (layout( location=0) in float)
-0:2 move second child to first child ( temp 4-component vector of float)
+0:22 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
-0:2 Function Call: @PixelShaderFunction(f1; ( temp 4-component vector of float)
+0:22 Function Call: @PixelShaderFunction(f1; ( temp 4-component vector of float)
0:? 'input' ( temp float)
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@@ -145,127 +199,176 @@
// Module Version 10000
// Generated by (magic number): 80007
-// Id's are bound by 71
+// Id's are bound by 99
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Fragment 4 "PixelShaderFunction" 64 67
+ EntryPoint Fragment 4 "PixelShaderFunction" 92 95
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "PixelShaderFunction"
- Name 11 "@PixelShaderFunction(f1;"
- Name 10 "input"
- Name 62 "input"
- Name 64 "input"
- Name 67 "@entryPointOutput"
- Name 68 "param"
- Decorate 64(input) Location 0
- Decorate 67(@entryPointOutput) Location 0
+ Name 6 "f0("
+ Name 8 "f1("
+ Name 14 "f2(f1;"
+ Name 13 "input"
+ Name 18 "f3(f1;"
+ Name 17 "input"
+ Name 21 "f4(f1;"
+ Name 20 "input"
+ Name 26 "@PixelShaderFunction(f1;"
+ Name 25 "input"
+ Name 77 "param"
+ Name 80 "param"
+ Name 83 "param"
+ Name 90 "input"
+ Name 92 "input"
+ Name 95 "@entryPointOutput"
+ Name 96 "param"
+ Decorate 92(input) Location 0
+ Decorate 95(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
- 6: TypeFloat 32
- 7: TypePointer Function 6(float)
- 8: TypeVector 6(float) 4
- 9: TypeFunction 8(fvec4) 7(ptr)
- 17: TypeBool
- 18: 17(bool) ConstantFalse
- 31: 6(float) Constant 1073741824
- 38: 6(float) Constant 1065353216
- 41: 6(float) Constant 1092616192
- 63: TypePointer Input 6(float)
- 64(input): 63(ptr) Variable Input
- 66: TypePointer Output 8(fvec4)
-67(@entryPointOutput): 66(ptr) Variable Output
+ 10: TypeFloat 32
+ 11: TypePointer Function 10(float)
+ 12: TypeFunction 10(float) 11(ptr)
+ 16: TypeFunction 2 11(ptr)
+ 23: TypeVector 10(float) 4
+ 24: TypeFunction 23(fvec4) 11(ptr)
+ 32: TypeBool
+ 33: 32(bool) ConstantFalse
+ 47: 10(float) Constant 1073741824
+ 55: 10(float) Constant 1065353216
+ 58: 10(float) Constant 1092616192
+ 91: TypePointer Input 10(float)
+ 92(input): 91(ptr) Variable Input
+ 94: TypePointer Output 23(fvec4)
+95(@entryPointOutput): 94(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3
5: Label
- 62(input): 7(ptr) Variable Function
- 68(param): 7(ptr) Variable Function
- 65: 6(float) Load 64(input)
- Store 62(input) 65
- 69: 6(float) Load 62(input)
- Store 68(param) 69
- 70: 8(fvec4) FunctionCall 11(@PixelShaderFunction(f1;) 68(param)
- Store 67(@entryPointOutput) 70
+ 90(input): 11(ptr) Variable Function
+ 96(param): 11(ptr) Variable Function
+ 93: 10(float) Load 92(input)
+ Store 90(input) 93
+ 97: 10(float) Load 90(input)
+ Store 96(param) 97
+ 98: 23(fvec4) FunctionCall 26(@PixelShaderFunction(f1;) 96(param)
+ Store 95(@entryPointOutput) 98
Return
FunctionEnd
-11(@PixelShaderFunction(f1;): 8(fvec4) Function None 9
- 10(input): 7(ptr) FunctionParameter
- 12: Label
- Branch 13
- 13: Label
- LoopMerge 15 16 Unroll
- Branch 14
- 14: Label
- Branch 16
- 16: Label
- BranchConditional 18 13 15
- 15: Label
- Branch 19
- 19: Label
- LoopMerge 21 22 Unroll
- Branch 20
- 20: Label
- Branch 22
- 22: Label
- BranchConditional 18 19 21
- 21: Label
- Branch 23
- 23: Label
- LoopMerge 25 26 None
- Branch 24
- 24: Label
- 27: 6(float) Load 10(input)
- 28: 8(fvec4) CompositeConstruct 27 27 27 27
- ReturnValue 28
- 26: Label
- 30: 6(float) Load 10(input)
- 32: 17(bool) FOrdGreaterThan 30 31
- BranchConditional 32 23 25
- 25: Label
- Branch 33
- 33: Label
- LoopMerge 35 36 None
+ 6(f0(): 2 Function None 3
+ 7: Label
+ Branch 28
+ 28: Label
+ LoopMerge 30 31 Unroll
+ Branch 29
+ 29: Label
+ Branch 31
+ 31: Label
+ BranchConditional 33 28 30
+ 30: Label
+ Return
+ FunctionEnd
+ 8(f1(): 2 Function None 3
+ 9: Label
Branch 34
34: Label
- 37: 6(float) Load 10(input)
- 39: 6(float) FAdd 37 38
- Store 10(input) 39
- Branch 36
- 36: Label
- 40: 6(float) Load 10(input)
- 42: 17(bool) FOrdLessThan 40 41
- BranchConditional 42 33 35
+ LoopMerge 36 37 Unroll
+ Branch 35
35: Label
- Branch 43
- 43: Label
- LoopMerge 45 46 None
- Branch 44
- 44: Label
- Branch 47
- 47: Label
- LoopMerge 49 50 None
+ Branch 37
+ 37: Label
+ BranchConditional 33 34 36
+ 36: Label
+ Return
+ FunctionEnd
+ 14(f2(f1;): 10(float) Function None 12
+ 13(input): 11(ptr) FunctionParameter
+ 15: Label
+ Branch 38
+ 38: Label
+ LoopMerge 40 41 None
+ Branch 39
+ 39: Label
+ 42: 10(float) Load 13(input)
+ 43: 23(fvec4) CompositeConstruct 42 42 42 42
+ 44: 10(float) CompositeExtract 43 0
+ ReturnValue 44
+ 41: Label
+ Branch 38
+ 40: Label
+ Unreachable
+ FunctionEnd
+ 18(f3(f1;): 2 Function None 16
+ 17(input): 11(ptr) FunctionParameter
+ 19: Label
+ Branch 50
+ 50: Label
+ LoopMerge 52 53 None
Branch 51
51: Label
- 52: 6(float) Load 10(input)
- 53: 6(float) FAdd 52 38
- Store 10(input) 53
- 54: 17(bool) FOrdLessThan 53 41
- BranchConditional 54 48 49
- 48: Label
- Branch 50
- 50: Label
- Branch 47
- 49: Label
- Branch 46
- 46: Label
- 55: 6(float) Load 10(input)
- 56: 6(float) FAdd 55 38
- Store 10(input) 56
- 57: 17(bool) FOrdLessThan 56 41
- BranchConditional 57 43 45
- 45: Label
- 58: 6(float) Load 10(input)
- 59: 8(fvec4) CompositeConstruct 58 58 58 58
- ReturnValue 59
+ 54: 10(float) Load 17(input)
+ 56: 10(float) FAdd 54 55
+ Store 17(input) 56
+ Branch 53
+ 53: Label
+ 57: 10(float) Load 17(input)
+ 59: 32(bool) FOrdLessThan 57 58
+ BranchConditional 59 50 52
+ 52: Label
+ Return
+ FunctionEnd
+ 21(f4(f1;): 2 Function None 16
+ 20(input): 11(ptr) FunctionParameter
+ 22: Label
+ Branch 60
+ 60: Label
+ LoopMerge 62 63 None
+ Branch 61
+ 61: Label
+ Branch 64
+ 64: Label
+ LoopMerge 66 67 None
+ Branch 68
+ 68: Label
+ 69: 10(float) Load 20(input)
+ 70: 10(float) FAdd 69 55
+ Store 20(input) 70
+ 71: 32(bool) FOrdLessThan 70 58
+ BranchConditional 71 65 66
+ 65: Label
+ Branch 67
+ 67: Label
+ Branch 64
+ 66: Label
+ Branch 63
+ 63: Label
+ 72: 10(float) Load 20(input)
+ 73: 10(float) FAdd 72 55
+ Store 20(input) 73
+ 74: 32(bool) FOrdLessThan 73 58
+ BranchConditional 74 60 62
+ 62: Label
+ Return
+ FunctionEnd
+26(@PixelShaderFunction(f1;): 23(fvec4) Function None 24
+ 25(input): 11(ptr) FunctionParameter
+ 27: Label
+ 77(param): 11(ptr) Variable Function
+ 80(param): 11(ptr) Variable Function
+ 83(param): 11(ptr) Variable Function
+ 75: 2 FunctionCall 6(f0()
+ 76: 2 FunctionCall 8(f1()
+ 78: 10(float) Load 25(input)
+ Store 77(param) 78
+ 79: 10(float) FunctionCall 14(f2(f1;) 77(param)
+ 81: 10(float) Load 25(input)
+ Store 80(param) 81
+ 82: 2 FunctionCall 18(f3(f1;) 80(param)
+ 84: 10(float) Load 25(input)
+ Store 83(param) 84
+ 85: 2 FunctionCall 21(f4(f1;) 83(param)
+ 86: 10(float) Load 25(input)
+ 87: 23(fvec4) CompositeConstruct 86 86 86 86
+ ReturnValue 87
FunctionEnd
diff --git a/Test/baseResults/hlsl.forLoop.frag.out b/Test/baseResults/hlsl.forLoop.frag.out
index 3e835f8..b8f59e8 100644
--- a/Test/baseResults/hlsl.forLoop.frag.out
+++ b/Test/baseResults/hlsl.forLoop.frag.out
@@ -2,197 +2,251 @@
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
-0:2 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
-0:2 Function Parameters:
-0:2 'input' ( in 4-component vector of float)
+0:1 Function Definition: f0( ( temp void)
+0:1 Function Parameters:
0:? Sequence
0:? Sequence
-0:3 Loop with condition tested first
-0:3 No loop condition
-0:3 No loop body
-0:4 Sequence
-0:4 Pre-Increment ( temp 4-component vector of float)
-0:4 'input' ( in 4-component vector of float)
-0:4 Loop with condition tested first
-0:4 No loop condition
-0:4 No loop body
-0:? Sequence
-0:5 Loop with condition tested first: Unroll
-0:5 Loop Condition
-0:5 any ( temp bool)
-0:5 NotEqual ( temp 4-component vector of bool)
-0:5 'input' ( in 4-component vector of float)
-0:5 'input' ( in 4-component vector of float)
-0:5 No loop body
-0:? Sequence
+0:2 Loop with condition tested first
+0:2 No loop condition
+0:2 No loop body
+0:5 Function Definition: f1(vf4; ( temp void)
+0:5 Function Parameters:
+0:5 'input' ( in 4-component vector of float)
+0:? Sequence
+0:6 Sequence
+0:6 Pre-Increment ( temp 4-component vector of float)
+0:6 'input' ( in 4-component vector of float)
0:6 Loop with condition tested first
-0:6 Loop Condition
-0:6 any ( temp bool)
-0:6 NotEqual ( temp 4-component vector of bool)
-0:6 'input' ( in 4-component vector of float)
-0:6 'input' ( in 4-component vector of float)
-0:6 Loop Body
-0:? Sequence
-0:6 Branch: Return with expression
-0:6 Negate value ( temp 4-component vector of float)
-0:6 'input' ( in 4-component vector of float)
-0:7 Sequence
-0:7 Pre-Decrement ( temp 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Loop with condition tested first
-0:7 Loop Condition
-0:7 any ( temp bool)
-0:7 NotEqual ( temp 4-component vector of bool)
-0:7 'input' ( in 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Loop Body
-0:? Sequence
-0:7 Branch: Return with expression
-0:7 Negate value ( temp 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Loop Terminal Expression
-0:7 add second child into first child ( temp 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Constant:
-0:7 2.000000
+0:6 No loop condition
+0:6 No loop body
+0:9 Function Definition: f2(vf4; ( temp void)
+0:9 Function Parameters:
+0:9 'input' ( in 4-component vector of float)
+0:? Sequence
0:? Sequence
-0:8 Loop with condition tested first
-0:8 No loop condition
-0:8 Loop Body
-0:8 Test condition and select ( temp void)
-0:8 Condition
-0:8 Compare Greater Than ( temp bool)
-0:8 direct index ( temp float)
-0:8 'input' ( in 4-component vector of float)
-0:8 Constant:
-0:8 0 (const int)
-0:8 Constant:
-0:8 2.000000
-0:8 true case
-0:8 Branch: Break
+0:10 Loop with condition tested first: Unroll
+0:10 Loop Condition
+0:10 any ( temp bool)
+0:10 NotEqual ( temp 4-component vector of bool)
+0:10 'input' ( in 4-component vector of float)
+0:10 'input' ( in 4-component vector of float)
+0:10 No loop body
+0:13 Function Definition: f3(vf4; ( temp float)
+0:13 Function Parameters:
+0:13 'input' ( in 4-component vector of float)
+0:? Sequence
0:? Sequence
-0:9 Loop with condition tested first
-0:9 No loop condition
-0:9 Loop Body
-0:9 Test condition and select ( temp void)
-0:9 Condition
-0:9 Compare Greater Than ( temp bool)
-0:9 direct index ( temp float)
-0:9 'input' ( in 4-component vector of float)
-0:9 Constant:
-0:9 0 (const int)
-0:9 Constant:
-0:9 2.000000
-0:9 true case
-0:9 Branch: Continue
-0:11 Sequence
-0:11 move second child to first child ( temp int)
-0:11 'ii' ( temp int)
-0:11 Constant:
-0:11 -1 (const int)
-0:11 Loop with condition tested first
-0:11 Loop Condition
-0:11 Compare Less Than ( temp bool)
-0:11 'ii' ( temp int)
-0:11 Constant:
-0:11 3 (const int)
-0:11 Loop Body
-0:11 Test condition and select ( temp void)
-0:11 Condition
-0:11 Compare Equal ( temp bool)
-0:11 'ii' ( temp int)
-0:11 Constant:
-0:11 2 (const int)
-0:11 true case
-0:11 Branch: Continue
-0:11 Loop Terminal Expression
-0:11 Pre-Increment ( temp int)
-0:11 'ii' ( temp int)
-0:12 Pre-Decrement ( temp float)
-0:12 'ii' ( temp float)
-0:13 Sequence
-0:13 move second child to first child ( temp int)
-0:13 'first' ( temp int)
-0:13 Constant:
-0:13 0 (const int)
-0:13 move second child to first child ( temp int)
-0:13 'second' ( temp int)
-0:13 Constant:
-0:13 1 (const int)
-0:13 Loop with condition tested first
-0:13 No loop condition
-0:13 Loop Body
-0:13 add ( temp int)
-0:13 'first' ( temp int)
-0:13 'second' ( temp int)
-0:14 Sequence
-0:14 move second child to first child ( temp int)
-0:14 'i' ( temp int)
-0:14 Constant:
-0:14 0 (const int)
-0:14 move second child to first child ( temp int)
-0:14 'count' ( temp int)
-0:14 Convert float to int ( temp int)
-0:14 'ii' ( temp float)
0:14 Loop with condition tested first
0:14 Loop Condition
-0:14 Compare Less Than ( temp bool)
-0:14 'i' ( temp int)
-0:14 'count' ( temp int)
-0:14 No loop body
-0:14 Loop Terminal Expression
-0:14 Post-Increment ( temp int)
-0:14 'i' ( temp int)
-0:15 Sequence
-0:15 move second child to first child ( temp float)
-0:15 'first' ( temp float)
-0:15 Constant:
-0:15 0.000000
-0:15 Loop with condition tested first
-0:15 Loop Condition
-0:15 Compare Less Than ( temp bool)
-0:15 'first' ( temp float)
-0:15 direct index ( temp float)
-0:15 'second' ( temp 2-element array of float)
-0:15 Constant:
-0:15 0 (const int)
-0:15 Loop Body
-0:15 add ( temp float)
-0:15 add ( temp float)
-0:15 'first' ( temp float)
-0:15 direct index ( temp float)
-0:15 'second' ( temp 2-element array of float)
-0:15 Constant:
-0:15 1 (const int)
-0:15 'third' ( temp float)
-0:15 Loop Terminal Expression
-0:15 Pre-Increment ( temp float)
-0:15 direct index ( temp float)
-0:15 'second' ( temp 2-element array of float)
-0:15 Constant:
-0:15 1 (const int)
-0:? Sequence
-0:16 Comma ( temp float)
-0:16 Comma ( temp float)
-0:16 Pre-Decrement ( temp float)
-0:16 'ii' ( temp float)
-0:16 Pre-Decrement ( temp float)
-0:16 'ii' ( temp float)
-0:16 Pre-Decrement ( temp float)
-0:16 'ii' ( temp float)
-0:16 Loop with condition tested first
-0:16 No loop condition
-0:16 Loop Body
-0:16 'ii' ( temp float)
-0:2 Function Definition: PixelShaderFunction( ( temp void)
-0:2 Function Parameters:
+0:14 any ( temp bool)
+0:14 NotEqual ( temp 4-component vector of bool)
+0:14 'input' ( in 4-component vector of float)
+0:14 'input' ( in 4-component vector of float)
+0:14 Loop Body
+0:? Sequence
+0:14 Branch: Return with expression
+0:14 Construct float ( temp float)
+0:14 Negate value ( temp 4-component vector of float)
+0:14 'input' ( in 4-component vector of float)
+0:17 Function Definition: f4(vf4; ( temp float)
+0:17 Function Parameters:
+0:17 'input' ( in 4-component vector of float)
0:? Sequence
-0:2 move second child to first child ( temp 4-component vector of float)
+0:18 Sequence
+0:18 Pre-Decrement ( temp 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Loop with condition tested first
+0:18 Loop Condition
+0:18 any ( temp bool)
+0:18 NotEqual ( temp 4-component vector of bool)
+0:18 'input' ( in 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Loop Body
+0:? Sequence
+0:18 Branch: Return with expression
+0:18 Construct float ( temp float)
+0:18 Negate value ( temp 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Loop Terminal Expression
+0:18 add second child into first child ( temp 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Constant:
+0:18 2.000000
+0:21 Function Definition: f5(vf4; ( temp void)
+0:21 Function Parameters:
+0:21 'input' ( in 4-component vector of float)
+0:? Sequence
+0:? Sequence
+0:22 Loop with condition tested first
+0:22 No loop condition
+0:22 Loop Body
+0:22 Test condition and select ( temp void)
+0:22 Condition
+0:22 Compare Greater Than ( temp bool)
+0:22 direct index ( temp float)
+0:22 'input' ( in 4-component vector of float)
+0:22 Constant:
+0:22 0 (const int)
+0:22 Constant:
+0:22 2.000000
+0:22 true case
+0:22 Branch: Break
+0:25 Function Definition: f6(vf4; ( temp void)
+0:25 Function Parameters:
+0:25 'input' ( in 4-component vector of float)
+0:? Sequence
+0:? Sequence
+0:26 Loop with condition tested first
+0:26 No loop condition
+0:26 Loop Body
+0:26 Test condition and select ( temp void)
+0:26 Condition
+0:26 Compare Greater Than ( temp bool)
+0:26 direct index ( temp float)
+0:26 'input' ( in 4-component vector of float)
+0:26 Constant:
+0:26 0 (const int)
+0:26 Constant:
+0:26 2.000000
+0:26 true case
+0:26 Branch: Continue
+0:29 Function Definition: f99( ( temp void)
+0:29 Function Parameters:
+0:? Sequence
+0:30 Sequence
+0:30 move second child to first child ( temp int)
+0:30 'first' ( temp int)
+0:30 Constant:
+0:30 0 (const int)
+0:30 move second child to first child ( temp int)
+0:30 'second' ( temp int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 Loop with condition tested first
+0:30 No loop condition
+0:30 Loop Body
+0:30 add ( temp int)
+0:30 'first' ( temp int)
+0:30 'second' ( temp int)
+0:33 Function Definition: f100(f1; ( temp void)
+0:33 Function Parameters:
+0:33 'ii' ( in float)
+0:? Sequence
+0:? Sequence
+0:34 Comma ( temp float)
+0:34 Comma ( temp float)
+0:34 Pre-Decrement ( temp float)
+0:34 'ii' ( in float)
+0:34 Pre-Decrement ( temp float)
+0:34 'ii' ( in float)
+0:34 Pre-Decrement ( temp float)
+0:34 'ii' ( in float)
+0:34 Loop with condition tested first
+0:34 No loop condition
+0:34 Loop Body
+0:34 'ii' ( in float)
+0:38 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:38 Function Parameters:
+0:38 'input' ( in 4-component vector of float)
+0:? Sequence
+0:39 Function Call: f0( ( temp void)
+0:40 Function Call: f1(vf4; ( temp void)
+0:40 'input' ( in 4-component vector of float)
+0:41 Function Call: f2(vf4; ( temp void)
+0:41 'input' ( in 4-component vector of float)
+0:42 Function Call: f3(vf4; ( temp float)
+0:42 'input' ( in 4-component vector of float)
+0:43 Function Call: f4(vf4; ( temp float)
+0:43 'input' ( in 4-component vector of float)
+0:44 Function Call: f5(vf4; ( temp void)
+0:44 'input' ( in 4-component vector of float)
+0:45 Function Call: f6(vf4; ( temp void)
+0:45 'input' ( in 4-component vector of float)
+0:48 Sequence
+0:48 move second child to first child ( temp int)
+0:48 'ii' ( temp int)
+0:48 Constant:
+0:48 -1 (const int)
+0:48 Loop with condition tested first
+0:48 Loop Condition
+0:48 Compare Less Than ( temp bool)
+0:48 'ii' ( temp int)
+0:48 Constant:
+0:48 3 (const int)
+0:48 Loop Body
+0:48 Test condition and select ( temp void)
+0:48 Condition
+0:48 Compare Equal ( temp bool)
+0:48 'ii' ( temp int)
+0:48 Constant:
+0:48 2 (const int)
+0:48 true case
+0:48 Branch: Continue
+0:48 Loop Terminal Expression
+0:48 Pre-Increment ( temp int)
+0:48 'ii' ( temp int)
+0:49 Pre-Decrement ( temp float)
+0:49 'ii' ( temp float)
+0:51 Function Call: f99( ( temp void)
+0:53 Sequence
+0:53 move second child to first child ( temp int)
+0:53 'i' ( temp int)
+0:53 Constant:
+0:53 0 (const int)
+0:53 move second child to first child ( temp int)
+0:53 'count' ( temp int)
+0:53 Convert float to int ( temp int)
+0:53 'ii' ( temp float)
+0:53 Loop with condition tested first
+0:53 Loop Condition
+0:53 Compare Less Than ( temp bool)
+0:53 'i' ( temp int)
+0:53 'count' ( temp int)
+0:53 No loop body
+0:53 Loop Terminal Expression
+0:53 Post-Increment ( temp int)
+0:53 'i' ( temp int)
+0:54 Sequence
+0:54 move second child to first child ( temp float)
+0:54 'first' ( temp float)
+0:54 Constant:
+0:54 0.000000
+0:54 Loop with condition tested first
+0:54 Loop Condition
+0:54 Compare Less Than ( temp bool)
+0:54 'first' ( temp float)
+0:54 direct index ( temp float)
+0:54 'second' ( temp 2-element array of float)
+0:54 Constant:
+0:54 0 (const int)
+0:54 Loop Body
+0:54 add ( temp float)
+0:54 add ( temp float)
+0:54 'first' ( temp float)
+0:54 direct index ( temp float)
+0:54 'second' ( temp 2-element array of float)
+0:54 Constant:
+0:54 1 (const int)
+0:54 'third' ( temp float)
+0:54 Loop Terminal Expression
+0:54 Pre-Increment ( temp float)
+0:54 direct index ( temp float)
+0:54 'second' ( temp 2-element array of float)
+0:54 Constant:
+0:54 1 (const int)
+0:56 Function Call: f100(f1; ( temp void)
+0:56 'ii' ( temp float)
+0:58 Branch: Return with expression
+0:58 'input' ( in 4-component vector of float)
+0:38 Function Definition: PixelShaderFunction( ( temp void)
+0:38 Function Parameters:
+0:? Sequence
+0:38 move second child to first child ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? 'input' (layout( location=0) in 4-component vector of float)
-0:2 move second child to first child ( temp 4-component vector of float)
+0:38 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
-0:2 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:38 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@@ -205,197 +259,251 @@
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
-0:2 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
-0:2 Function Parameters:
-0:2 'input' ( in 4-component vector of float)
+0:1 Function Definition: f0( ( temp void)
+0:1 Function Parameters:
0:? Sequence
0:? Sequence
-0:3 Loop with condition tested first
-0:3 No loop condition
-0:3 No loop body
-0:4 Sequence
-0:4 Pre-Increment ( temp 4-component vector of float)
-0:4 'input' ( in 4-component vector of float)
-0:4 Loop with condition tested first
-0:4 No loop condition
-0:4 No loop body
-0:? Sequence
-0:5 Loop with condition tested first: Unroll
-0:5 Loop Condition
-0:5 any ( temp bool)
-0:5 NotEqual ( temp 4-component vector of bool)
-0:5 'input' ( in 4-component vector of float)
-0:5 'input' ( in 4-component vector of float)
-0:5 No loop body
-0:? Sequence
+0:2 Loop with condition tested first
+0:2 No loop condition
+0:2 No loop body
+0:5 Function Definition: f1(vf4; ( temp void)
+0:5 Function Parameters:
+0:5 'input' ( in 4-component vector of float)
+0:? Sequence
+0:6 Sequence
+0:6 Pre-Increment ( temp 4-component vector of float)
+0:6 'input' ( in 4-component vector of float)
0:6 Loop with condition tested first
-0:6 Loop Condition
-0:6 any ( temp bool)
-0:6 NotEqual ( temp 4-component vector of bool)
-0:6 'input' ( in 4-component vector of float)
-0:6 'input' ( in 4-component vector of float)
-0:6 Loop Body
-0:? Sequence
-0:6 Branch: Return with expression
-0:6 Negate value ( temp 4-component vector of float)
-0:6 'input' ( in 4-component vector of float)
-0:7 Sequence
-0:7 Pre-Decrement ( temp 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Loop with condition tested first
-0:7 Loop Condition
-0:7 any ( temp bool)
-0:7 NotEqual ( temp 4-component vector of bool)
-0:7 'input' ( in 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Loop Body
-0:? Sequence
-0:7 Branch: Return with expression
-0:7 Negate value ( temp 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Loop Terminal Expression
-0:7 add second child into first child ( temp 4-component vector of float)
-0:7 'input' ( in 4-component vector of float)
-0:7 Constant:
-0:7 2.000000
+0:6 No loop condition
+0:6 No loop body
+0:9 Function Definition: f2(vf4; ( temp void)
+0:9 Function Parameters:
+0:9 'input' ( in 4-component vector of float)
+0:? Sequence
0:? Sequence
-0:8 Loop with condition tested first
-0:8 No loop condition
-0:8 Loop Body
-0:8 Test condition and select ( temp void)
-0:8 Condition
-0:8 Compare Greater Than ( temp bool)
-0:8 direct index ( temp float)
-0:8 'input' ( in 4-component vector of float)
-0:8 Constant:
-0:8 0 (const int)
-0:8 Constant:
-0:8 2.000000
-0:8 true case
-0:8 Branch: Break
+0:10 Loop with condition tested first: Unroll
+0:10 Loop Condition
+0:10 any ( temp bool)
+0:10 NotEqual ( temp 4-component vector of bool)
+0:10 'input' ( in 4-component vector of float)
+0:10 'input' ( in 4-component vector of float)
+0:10 No loop body
+0:13 Function Definition: f3(vf4; ( temp float)
+0:13 Function Parameters:
+0:13 'input' ( in 4-component vector of float)
+0:? Sequence
0:? Sequence
-0:9 Loop with condition tested first
-0:9 No loop condition
-0:9 Loop Body
-0:9 Test condition and select ( temp void)
-0:9 Condition
-0:9 Compare Greater Than ( temp bool)
-0:9 direct index ( temp float)
-0:9 'input' ( in 4-component vector of float)
-0:9 Constant:
-0:9 0 (const int)
-0:9 Constant:
-0:9 2.000000
-0:9 true case
-0:9 Branch: Continue
-0:11 Sequence
-0:11 move second child to first child ( temp int)
-0:11 'ii' ( temp int)
-0:11 Constant:
-0:11 -1 (const int)
-0:11 Loop with condition tested first
-0:11 Loop Condition
-0:11 Compare Less Than ( temp bool)
-0:11 'ii' ( temp int)
-0:11 Constant:
-0:11 3 (const int)
-0:11 Loop Body
-0:11 Test condition and select ( temp void)
-0:11 Condition
-0:11 Compare Equal ( temp bool)
-0:11 'ii' ( temp int)
-0:11 Constant:
-0:11 2 (const int)
-0:11 true case
-0:11 Branch: Continue
-0:11 Loop Terminal Expression
-0:11 Pre-Increment ( temp int)
-0:11 'ii' ( temp int)
-0:12 Pre-Decrement ( temp float)
-0:12 'ii' ( temp float)
-0:13 Sequence
-0:13 move second child to first child ( temp int)
-0:13 'first' ( temp int)
-0:13 Constant:
-0:13 0 (const int)
-0:13 move second child to first child ( temp int)
-0:13 'second' ( temp int)
-0:13 Constant:
-0:13 1 (const int)
-0:13 Loop with condition tested first
-0:13 No loop condition
-0:13 Loop Body
-0:13 add ( temp int)
-0:13 'first' ( temp int)
-0:13 'second' ( temp int)
-0:14 Sequence
-0:14 move second child to first child ( temp int)
-0:14 'i' ( temp int)
-0:14 Constant:
-0:14 0 (const int)
-0:14 move second child to first child ( temp int)
-0:14 'count' ( temp int)
-0:14 Convert float to int ( temp int)
-0:14 'ii' ( temp float)
0:14 Loop with condition tested first
0:14 Loop Condition
-0:14 Compare Less Than ( temp bool)
-0:14 'i' ( temp int)
-0:14 'count' ( temp int)
-0:14 No loop body
-0:14 Loop Terminal Expression
-0:14 Post-Increment ( temp int)
-0:14 'i' ( temp int)
-0:15 Sequence
-0:15 move second child to first child ( temp float)
-0:15 'first' ( temp float)
-0:15 Constant:
-0:15 0.000000
-0:15 Loop with condition tested first
-0:15 Loop Condition
-0:15 Compare Less Than ( temp bool)
-0:15 'first' ( temp float)
-0:15 direct index ( temp float)
-0:15 'second' ( temp 2-element array of float)
-0:15 Constant:
-0:15 0 (const int)
-0:15 Loop Body
-0:15 add ( temp float)
-0:15 add ( temp float)
-0:15 'first' ( temp float)
-0:15 direct index ( temp float)
-0:15 'second' ( temp 2-element array of float)
-0:15 Constant:
-0:15 1 (const int)
-0:15 'third' ( temp float)
-0:15 Loop Terminal Expression
-0:15 Pre-Increment ( temp float)
-0:15 direct index ( temp float)
-0:15 'second' ( temp 2-element array of float)
-0:15 Constant:
-0:15 1 (const int)
-0:? Sequence
-0:16 Comma ( temp float)
-0:16 Comma ( temp float)
-0:16 Pre-Decrement ( temp float)
-0:16 'ii' ( temp float)
-0:16 Pre-Decrement ( temp float)
-0:16 'ii' ( temp float)
-0:16 Pre-Decrement ( temp float)
-0:16 'ii' ( temp float)
-0:16 Loop with condition tested first
-0:16 No loop condition
-0:16 Loop Body
-0:16 'ii' ( temp float)
-0:2 Function Definition: PixelShaderFunction( ( temp void)
-0:2 Function Parameters:
+0:14 any ( temp bool)
+0:14 NotEqual ( temp 4-component vector of bool)
+0:14 'input' ( in 4-component vector of float)
+0:14 'input' ( in 4-component vector of float)
+0:14 Loop Body
+0:? Sequence
+0:14 Branch: Return with expression
+0:14 Construct float ( temp float)
+0:14 Negate value ( temp 4-component vector of float)
+0:14 'input' ( in 4-component vector of float)
+0:17 Function Definition: f4(vf4; ( temp float)
+0:17 Function Parameters:
+0:17 'input' ( in 4-component vector of float)
0:? Sequence
-0:2 move second child to first child ( temp 4-component vector of float)
+0:18 Sequence
+0:18 Pre-Decrement ( temp 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Loop with condition tested first
+0:18 Loop Condition
+0:18 any ( temp bool)
+0:18 NotEqual ( temp 4-component vector of bool)
+0:18 'input' ( in 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Loop Body
+0:? Sequence
+0:18 Branch: Return with expression
+0:18 Construct float ( temp float)
+0:18 Negate value ( temp 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Loop Terminal Expression
+0:18 add second child into first child ( temp 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 Constant:
+0:18 2.000000
+0:21 Function Definition: f5(vf4; ( temp void)
+0:21 Function Parameters:
+0:21 'input' ( in 4-component vector of float)
+0:? Sequence
+0:? Sequence
+0:22 Loop with condition tested first
+0:22 No loop condition
+0:22 Loop Body
+0:22 Test condition and select ( temp void)
+0:22 Condition
+0:22 Compare Greater Than ( temp bool)
+0:22 direct index ( temp float)
+0:22 'input' ( in 4-component vector of float)
+0:22 Constant:
+0:22 0 (const int)
+0:22 Constant:
+0:22 2.000000
+0:22 true case
+0:22 Branch: Break
+0:25 Function Definition: f6(vf4; ( temp void)
+0:25 Function Parameters:
+0:25 'input' ( in 4-component vector of float)
+0:? Sequence
+0:? Sequence
+0:26 Loop with condition tested first
+0:26 No loop condition
+0:26 Loop Body
+0:26 Test condition and select ( temp void)
+0:26 Condition
+0:26 Compare Greater Than ( temp bool)
+0:26 direct index ( temp float)
+0:26 'input' ( in 4-component vector of float)
+0:26 Constant:
+0:26 0 (const int)
+0:26 Constant:
+0:26 2.000000
+0:26 true case
+0:26 Branch: Continue
+0:29 Function Definition: f99( ( temp void)
+0:29 Function Parameters:
+0:? Sequence
+0:30 Sequence
+0:30 move second child to first child ( temp int)
+0:30 'first' ( temp int)
+0:30 Constant:
+0:30 0 (const int)
+0:30 move second child to first child ( temp int)
+0:30 'second' ( temp int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 Loop with condition tested first
+0:30 No loop condition
+0:30 Loop Body
+0:30 add ( temp int)
+0:30 'first' ( temp int)
+0:30 'second' ( temp int)
+0:33 Function Definition: f100(f1; ( temp void)
+0:33 Function Parameters:
+0:33 'ii' ( in float)
+0:? Sequence
+0:? Sequence
+0:34 Comma ( temp float)
+0:34 Comma ( temp float)
+0:34 Pre-Decrement ( temp float)
+0:34 'ii' ( in float)
+0:34 Pre-Decrement ( temp float)
+0:34 'ii' ( in float)
+0:34 Pre-Decrement ( temp float)
+0:34 'ii' ( in float)
+0:34 Loop with condition tested first
+0:34 No loop condition
+0:34 Loop Body
+0:34 'ii' ( in float)
+0:38 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:38 Function Parameters:
+0:38 'input' ( in 4-component vector of float)
+0:? Sequence
+0:39 Function Call: f0( ( temp void)
+0:40 Function Call: f1(vf4; ( temp void)
+0:40 'input' ( in 4-component vector of float)
+0:41 Function Call: f2(vf4; ( temp void)
+0:41 'input' ( in 4-component vector of float)
+0:42 Function Call: f3(vf4; ( temp float)
+0:42 'input' ( in 4-component vector of float)
+0:43 Function Call: f4(vf4; ( temp float)
+0:43 'input' ( in 4-component vector of float)
+0:44 Function Call: f5(vf4; ( temp void)
+0:44 'input' ( in 4-component vector of float)
+0:45 Function Call: f6(vf4; ( temp void)
+0:45 'input' ( in 4-component vector of float)
+0:48 Sequence
+0:48 move second child to first child ( temp int)
+0:48 'ii' ( temp int)
+0:48 Constant:
+0:48 -1 (const int)
+0:48 Loop with condition tested first
+0:48 Loop Condition
+0:48 Compare Less Than ( temp bool)
+0:48 'ii' ( temp int)
+0:48 Constant:
+0:48 3 (const int)
+0:48 Loop Body
+0:48 Test condition and select ( temp void)
+0:48 Condition
+0:48 Compare Equal ( temp bool)
+0:48 'ii' ( temp int)
+0:48 Constant:
+0:48 2 (const int)
+0:48 true case
+0:48 Branch: Continue
+0:48 Loop Terminal Expression
+0:48 Pre-Increment ( temp int)
+0:48 'ii' ( temp int)
+0:49 Pre-Decrement ( temp float)
+0:49 'ii' ( temp float)
+0:51 Function Call: f99( ( temp void)
+0:53 Sequence
+0:53 move second child to first child ( temp int)
+0:53 'i' ( temp int)
+0:53 Constant:
+0:53 0 (const int)
+0:53 move second child to first child ( temp int)
+0:53 'count' ( temp int)
+0:53 Convert float to int ( temp int)
+0:53 'ii' ( temp float)
+0:53 Loop with condition tested first
+0:53 Loop Condition
+0:53 Compare Less Than ( temp bool)
+0:53 'i' ( temp int)
+0:53 'count' ( temp int)
+0:53 No loop body
+0:53 Loop Terminal Expression
+0:53 Post-Increment ( temp int)
+0:53 'i' ( temp int)
+0:54 Sequence
+0:54 move second child to first child ( temp float)
+0:54 'first' ( temp float)
+0:54 Constant:
+0:54 0.000000
+0:54 Loop with condition tested first
+0:54 Loop Condition
+0:54 Compare Less Than ( temp bool)
+0:54 'first' ( temp float)
+0:54 direct index ( temp float)
+0:54 'second' ( temp 2-element array of float)
+0:54 Constant:
+0:54 0 (const int)
+0:54 Loop Body
+0:54 add ( temp float)
+0:54 add ( temp float)
+0:54 'first' ( temp float)
+0:54 direct index ( temp float)
+0:54 'second' ( temp 2-element array of float)
+0:54 Constant:
+0:54 1 (const int)
+0:54 'third' ( temp float)
+0:54 Loop Terminal Expression
+0:54 Pre-Increment ( temp float)
+0:54 direct index ( temp float)
+0:54 'second' ( temp 2-element array of float)
+0:54 Constant:
+0:54 1 (const int)
+0:56 Function Call: f100(f1; ( temp void)
+0:56 'ii' ( temp float)
+0:58 Branch: Return with expression
+0:58 'input' ( in 4-component vector of float)
+0:38 Function Definition: PixelShaderFunction( ( temp void)
+0:38 Function Parameters:
+0:? Sequence
+0:38 move second child to first child ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? 'input' (layout( location=0) in 4-component vector of float)
-0:2 move second child to first child ( temp 4-component vector of float)
+0:38 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
-0:2 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:38 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@@ -403,303 +511,402 @@
// Module Version 10000
// Generated by (magic number): 80007
-// Id's are bound by 183
+// Id's are bound by 240
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Fragment 4 "PixelShaderFunction" 176 179
+ EntryPoint Fragment 4 "PixelShaderFunction" 233 236
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "PixelShaderFunction"
- Name 11 "@PixelShaderFunction(vf4;"
- Name 10 "input"
- Name 92 "ii"
- Name 111 "ii"
- Name 114 "first"
- Name 116 "second"
- Name 124 "i"
- Name 125 "count"
- Name 138 "first"
- Name 149 "second"
- Name 157 "third"
- Name 174 "input"
- Name 176 "input"
- Name 179 "@entryPointOutput"
- Name 180 "param"
- Decorate 176(input) Location 0
- Decorate 179(@entryPointOutput) Location 0
+ Name 6 "f0("
+ Name 13 "f1(vf4;"
+ Name 12 "input"
+ Name 16 "f2(vf4;"
+ Name 15 "input"
+ Name 20 "f3(vf4;"
+ Name 19 "input"
+ Name 23 "f4(vf4;"
+ Name 22 "input"
+ Name 26 "f5(vf4;"
+ Name 25 "input"
+ Name 29 "f6(vf4;"
+ Name 28 "input"
+ Name 31 "f99("
+ Name 36 "f100(f1;"
+ Name 35 "ii"
+ Name 40 "@PixelShaderFunction(vf4;"
+ Name 39 "input"
+ Name 124 "first"
+ Name 126 "second"
+ Name 146 "param"
+ Name 149 "param"
+ Name 152 "param"
+ Name 155 "param"
+ Name 158 "param"
+ Name 161 "param"
+ Name 164 "ii"
+ Name 182 "ii"
+ Name 186 "i"
+ Name 187 "count"
+ Name 200 "first"
+ Name 211 "second"
+ Name 219 "third"
+ Name 225 "param"
+ Name 231 "input"
+ Name 233 "input"
+ Name 236 "@entryPointOutput"
+ Name 237 "param"
+ Decorate 233(input) Location 0
+ Decorate 236(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
- 6: TypeFloat 32
- 7: TypeVector 6(float) 4
- 8: TypePointer Function 7(fvec4)
- 9: TypeFunction 7(fvec4) 8(ptr)
- 18: 6(float) Constant 1065353216
- 32: TypeBool
- 33: TypeVector 32(bool) 4
- 63: 6(float) Constant 1073741824
- 71: TypeInt 32 0
- 72: 71(int) Constant 0
- 73: TypePointer Function 6(float)
- 90: TypeInt 32 1
- 91: TypePointer Function 90(int)
- 93: 90(int) Constant 4294967295
- 100: 90(int) Constant 3
- 103: 90(int) Constant 2
- 109: 90(int) Constant 1
- 115: 90(int) Constant 0
- 139: 6(float) Constant 0
- 146: 71(int) Constant 2
- 147: TypeArray 6(float) 146
- 148: TypePointer Function 147
- 175: TypePointer Input 7(fvec4)
- 176(input): 175(ptr) Variable Input
- 178: TypePointer Output 7(fvec4)
-179(@entryPointOutput): 178(ptr) Variable Output
+ 8: TypeFloat 32
+ 9: TypeVector 8(float) 4
+ 10: TypePointer Function 9(fvec4)
+ 11: TypeFunction 2 10(ptr)
+ 18: TypeFunction 8(float) 10(ptr)
+ 33: TypePointer Function 8(float)
+ 34: TypeFunction 2 33(ptr)
+ 38: TypeFunction 9(fvec4) 10(ptr)
+ 47: 8(float) Constant 1065353216
+ 61: TypeBool
+ 62: TypeVector 61(bool) 4
+ 95: 8(float) Constant 1073741824
+ 104: TypeInt 32 0
+ 105: 104(int) Constant 0
+ 122: TypeInt 32 1
+ 123: TypePointer Function 122(int)
+ 125: 122(int) Constant 0
+ 127: 122(int) Constant 1
+ 165: 122(int) Constant 4294967295
+ 172: 122(int) Constant 3
+ 175: 122(int) Constant 2
+ 201: 8(float) Constant 0
+ 208: 104(int) Constant 2
+ 209: TypeArray 8(float) 208
+ 210: TypePointer Function 209
+ 232: TypePointer Input 9(fvec4)
+ 233(input): 232(ptr) Variable Input
+ 235: TypePointer Output 9(fvec4)
+236(@entryPointOutput): 235(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3
5: Label
- 174(input): 8(ptr) Variable Function
- 180(param): 8(ptr) Variable Function
- 177: 7(fvec4) Load 176(input)
- Store 174(input) 177
- 181: 7(fvec4) Load 174(input)
- Store 180(param) 181
- 182: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 180(param)
- Store 179(@entryPointOutput) 182
+ 231(input): 10(ptr) Variable Function
+ 237(param): 10(ptr) Variable Function
+ 234: 9(fvec4) Load 233(input)
+ Store 231(input) 234
+ 238: 9(fvec4) Load 231(input)
+ Store 237(param) 238
+ 239: 9(fvec4) FunctionCall 40(@PixelShaderFunction(vf4;) 237(param)
+ Store 236(@entryPointOutput) 239
Return
FunctionEnd
-11(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9
- 10(input): 8(ptr) FunctionParameter
- 12: Label
- 92(ii): 91(ptr) Variable Function
- 111(ii): 73(ptr) Variable Function
- 114(first): 91(ptr) Variable Function
- 116(second): 91(ptr) Variable Function
- 124(i): 91(ptr) Variable Function
- 125(count): 91(ptr) Variable Function
- 138(first): 73(ptr) Variable Function
- 149(second): 148(ptr) Variable Function
- 157(third): 73(ptr) Variable Function
- Branch 13
- 13: Label
- LoopMerge 15 16 None
- Branch 14
+ 6(f0(): 2 Function None 3
+ 7: Label
+ Branch 42
+ 42: Label
+ LoopMerge 44 45 None
+ Branch 43
+ 43: Label
+ Branch 45
+ 45: Label
+ Branch 42
+ 44: Label
+ Unreachable
+ FunctionEnd
+ 13(f1(vf4;): 2 Function None 11
+ 12(input): 10(ptr) FunctionParameter
14: Label
- Branch 16
- 16: Label
- Branch 13
- 15: Label
- 17: 7(fvec4) Load 10(input)
- 19: 7(fvec4) CompositeConstruct 18 18 18 18
- 20: 7(fvec4) FAdd 17 19
- Store 10(input) 20
- Branch 21
- 21: Label
- LoopMerge 23 24 None
- Branch 22
- 22: Label
- Branch 24
- 24: Label
- Branch 21
- 23: Label
- Branch 25
- 25: Label
- LoopMerge 27 28 Unroll
- Branch 29
- 29: Label
- 30: 7(fvec4) Load 10(input)
- 31: 7(fvec4) Load 10(input)
- 34: 33(bvec4) FOrdNotEqual 30 31
- 35: 32(bool) Any 34
- BranchConditional 35 26 27
- 26: Label
- Branch 28
- 28: Label
- Branch 25
- 27: Label
- Branch 36
- 36: Label
- LoopMerge 38 39 None
- Branch 40
- 40: Label
- 41: 7(fvec4) Load 10(input)
- 42: 7(fvec4) Load 10(input)
- 43: 33(bvec4) FOrdNotEqual 41 42
- 44: 32(bool) Any 43
- BranchConditional 44 37 38
- 37: Label
- 45: 7(fvec4) Load 10(input)
- 46: 7(fvec4) FNegate 45
- ReturnValue 46
- 39: Label
- Branch 36
- 38: Label
- 48: 7(fvec4) Load 10(input)
- 49: 7(fvec4) CompositeConstruct 18 18 18 18
- 50: 7(fvec4) FSub 48 49
- Store 10(input) 50
+ 46: 9(fvec4) Load 12(input)
+ 48: 9(fvec4) CompositeConstruct 47 47 47 47
+ 49: 9(fvec4) FAdd 46 48
+ Store 12(input) 49
+ Branch 50
+ 50: Label
+ LoopMerge 52 53 None
Branch 51
51: Label
- LoopMerge 53 54 None
- Branch 55
- 55: Label
- 56: 7(fvec4) Load 10(input)
- 57: 7(fvec4) Load 10(input)
- 58: 33(bvec4) FOrdNotEqual 56 57
- 59: 32(bool) Any 58
- BranchConditional 59 52 53
- 52: Label
- 60: 7(fvec4) Load 10(input)
- 61: 7(fvec4) FNegate 60
- ReturnValue 61
- 54: Label
- 64: 7(fvec4) Load 10(input)
- 65: 7(fvec4) CompositeConstruct 63 63 63 63
- 66: 7(fvec4) FAdd 64 65
- Store 10(input) 66
- Branch 51
+ Branch 53
53: Label
- Branch 67
- 67: Label
- LoopMerge 69 70 None
- Branch 68
- 68: Label
- 74: 73(ptr) AccessChain 10(input) 72
- 75: 6(float) Load 74
- 76: 32(bool) FOrdGreaterThan 75 63
- SelectionMerge 78 None
- BranchConditional 76 77 78
- 77: Label
- Branch 69
- 78: Label
- Branch 70
- 70: Label
- Branch 67
+ Branch 50
+ 52: Label
+ Unreachable
+ FunctionEnd
+ 16(f2(vf4;): 2 Function None 11
+ 15(input): 10(ptr) FunctionParameter
+ 17: Label
+ Branch 54
+ 54: Label
+ LoopMerge 56 57 Unroll
+ Branch 58
+ 58: Label
+ 59: 9(fvec4) Load 15(input)
+ 60: 9(fvec4) Load 15(input)
+ 63: 62(bvec4) FOrdNotEqual 59 60
+ 64: 61(bool) Any 63
+ BranchConditional 64 55 56
+ 55: Label
+ Branch 57
+ 57: Label
+ Branch 54
+ 56: Label
+ Return
+ FunctionEnd
+ 20(f3(vf4;): 8(float) Function None 18
+ 19(input): 10(ptr) FunctionParameter
+ 21: Label
+ Branch 65
+ 65: Label
+ LoopMerge 67 68 None
+ Branch 69
69: Label
- Branch 80
- 80: Label
- LoopMerge 82 83 None
- Branch 81
- 81: Label
- 84: 73(ptr) AccessChain 10(input) 72
- 85: 6(float) Load 84
- 86: 32(bool) FOrdGreaterThan 85 63
- SelectionMerge 88 None
- BranchConditional 86 87 88
- 87: Label
- Branch 83
- 88: Label
- Branch 83
- 83: Label
- Branch 80
+ 70: 9(fvec4) Load 19(input)
+ 71: 9(fvec4) Load 19(input)
+ 72: 62(bvec4) FOrdNotEqual 70 71
+ 73: 61(bool) Any 72
+ BranchConditional 73 66 67
+ 66: Label
+ 74: 9(fvec4) Load 19(input)
+ 75: 9(fvec4) FNegate 74
+ 76: 8(float) CompositeExtract 75 0
+ ReturnValue 76
+ 68: Label
+ Branch 65
+ 67: Label
+ 78: 8(float) Undef
+ ReturnValue 78
+ FunctionEnd
+ 23(f4(vf4;): 8(float) Function None 18
+ 22(input): 10(ptr) FunctionParameter
+ 24: Label
+ 79: 9(fvec4) Load 22(input)
+ 80: 9(fvec4) CompositeConstruct 47 47 47 47
+ 81: 9(fvec4) FSub 79 80
+ Store 22(input) 81
+ Branch 82
82: Label
- Store 92(ii) 93
- Branch 94
- 94: Label
- LoopMerge 96 97 None
- Branch 98
- 98: Label
- 99: 90(int) Load 92(ii)
- 101: 32(bool) SLessThan 99 100
- BranchConditional 101 95 96
- 95: Label
- 102: 90(int) Load 92(ii)
- 104: 32(bool) IEqual 102 103
- SelectionMerge 106 None
- BranchConditional 104 105 106
- 105: Label
- Branch 97
- 106: Label
- Branch 97
- 97: Label
- 108: 90(int) Load 92(ii)
- 110: 90(int) IAdd 108 109
- Store 92(ii) 110
- Branch 94
- 96: Label
- 112: 6(float) Load 111(ii)
- 113: 6(float) FSub 112 18
- Store 111(ii) 113
- Store 114(first) 115
- Store 116(second) 109
- Branch 117
- 117: Label
- LoopMerge 119 120 None
- Branch 118
- 118: Label
- 121: 90(int) Load 114(first)
- 122: 90(int) Load 116(second)
- 123: 90(int) IAdd 121 122
- Branch 120
+ LoopMerge 84 85 None
+ Branch 86
+ 86: Label
+ 87: 9(fvec4) Load 22(input)
+ 88: 9(fvec4) Load 22(input)
+ 89: 62(bvec4) FOrdNotEqual 87 88
+ 90: 61(bool) Any 89
+ BranchConditional 90 83 84
+ 83: Label
+ 91: 9(fvec4) Load 22(input)
+ 92: 9(fvec4) FNegate 91
+ 93: 8(float) CompositeExtract 92 0
+ ReturnValue 93
+ 85: Label
+ Branch 82
+ 84: Label
+ 99: 8(float) Undef
+ ReturnValue 99
+ FunctionEnd
+ 26(f5(vf4;): 2 Function None 11
+ 25(input): 10(ptr) FunctionParameter
+ 27: Label
+ Branch 100
+ 100: Label
+ LoopMerge 102 103 None
+ Branch 101
+ 101: Label
+ 106: 33(ptr) AccessChain 25(input) 105
+ 107: 8(float) Load 106
+ 108: 61(bool) FOrdGreaterThan 107 95
+ SelectionMerge 110 None
+ BranchConditional 108 109 110
+ 109: Label
+ Branch 102
+ 110: Label
+ Branch 103
+ 103: Label
+ Branch 100
+ 102: Label
+ Return
+ FunctionEnd
+ 29(f6(vf4;): 2 Function None 11
+ 28(input): 10(ptr) FunctionParameter
+ 30: Label
+ Branch 112
+ 112: Label
+ LoopMerge 114 115 None
+ Branch 113
+ 113: Label
+ 116: 33(ptr) AccessChain 28(input) 105
+ 117: 8(float) Load 116
+ 118: 61(bool) FOrdGreaterThan 117 95
+ SelectionMerge 120 None
+ BranchConditional 118 119 120
+ 119: Label
+ Branch 115
120: Label
- Branch 117
- 119: Label
- Store 124(i) 115
- 126: 6(float) Load 111(ii)
- 127: 90(int) ConvertFToS 126
- Store 125(count) 127
+ Branch 115
+ 115: Label
+ Branch 112
+ 114: Label
+ Unreachable
+ FunctionEnd
+ 31(f99(): 2 Function None 3
+ 32: Label
+ 124(first): 123(ptr) Variable Function
+ 126(second): 123(ptr) Variable Function
+ Store 124(first) 125
+ Store 126(second) 127
Branch 128
128: Label
LoopMerge 130 131 None
- Branch 132
- 132: Label
- 133: 90(int) Load 124(i)
- 134: 90(int) Load 125(count)
- 135: 32(bool) SLessThan 133 134
- BranchConditional 135 129 130
- 129: Label
- Branch 131
- 131: Label
- 136: 90(int) Load 124(i)
- 137: 90(int) IAdd 136 109
- Store 124(i) 137
- Branch 128
+ Branch 129
+ 129: Label
+ 132: 122(int) Load 124(first)
+ 133: 122(int) Load 126(second)
+ 134: 122(int) IAdd 132 133
+ Branch 131
+ 131: Label
+ Branch 128
130: Label
- Store 138(first) 139
- Branch 140
- 140: Label
- LoopMerge 142 143 None
+ Unreachable
+ FunctionEnd
+ 36(f100(f1;): 2 Function None 34
+ 35(ii): 33(ptr) FunctionParameter
+ 37: Label
+ 135: 8(float) Load 35(ii)
+ 136: 8(float) FSub 135 47
+ Store 35(ii) 136
+ 137: 8(float) Load 35(ii)
+ 138: 8(float) FSub 137 47
+ Store 35(ii) 138
+ 139: 8(float) Load 35(ii)
+ 140: 8(float) FSub 139 47
+ Store 35(ii) 140
+ Branch 141
+ 141: Label
+ LoopMerge 143 144 None
+ Branch 142
+ 142: Label
Branch 144
144: Label
- 145: 6(float) Load 138(first)
- 150: 73(ptr) AccessChain 149(second) 115
- 151: 6(float) Load 150
- 152: 32(bool) FOrdLessThan 145 151
- BranchConditional 152 141 142
- 141: Label
- 153: 6(float) Load 138(first)
- 154: 73(ptr) AccessChain 149(second) 109
- 155: 6(float) Load 154
- 156: 6(float) FAdd 153 155
- 158: 6(float) Load 157(third)
- 159: 6(float) FAdd 156 158
- Branch 143
- 143: Label
- 160: 73(ptr) AccessChain 149(second) 109
- 161: 6(float) Load 160
- 162: 6(float) FAdd 161 18
- Store 160 162
- Branch 140
- 142: Label
- 163: 6(float) Load 111(ii)
- 164: 6(float) FSub 163 18
- Store 111(ii) 164
- 165: 6(float) Load 111(ii)
- 166: 6(float) FSub 165 18
- Store 111(ii) 166
- 167: 6(float) Load 111(ii)
- 168: 6(float) FSub 167 18
- Store 111(ii) 168
- Branch 169
- 169: Label
- LoopMerge 171 172 None
+ Branch 141
+ 143: Label
+ Unreachable
+ FunctionEnd
+40(@PixelShaderFunction(vf4;): 9(fvec4) Function None 38
+ 39(input): 10(ptr) FunctionParameter
+ 41: Label
+ 146(param): 10(ptr) Variable Function
+ 149(param): 10(ptr) Variable Function
+ 152(param): 10(ptr) Variable Function
+ 155(param): 10(ptr) Variable Function
+ 158(param): 10(ptr) Variable Function
+ 161(param): 10(ptr) Variable Function
+ 164(ii): 123(ptr) Variable Function
+ 182(ii): 33(ptr) Variable Function
+ 186(i): 123(ptr) Variable Function
+ 187(count): 123(ptr) Variable Function
+ 200(first): 33(ptr) Variable Function
+ 211(second): 210(ptr) Variable Function
+ 219(third): 33(ptr) Variable Function
+ 225(param): 33(ptr) Variable Function
+ 145: 2 FunctionCall 6(f0()
+ 147: 9(fvec4) Load 39(input)
+ Store 146(param) 147
+ 148: 2 FunctionCall 13(f1(vf4;) 146(param)
+ 150: 9(fvec4) Load 39(input)
+ Store 149(param) 150
+ 151: 2 FunctionCall 16(f2(vf4;) 149(param)
+ 153: 9(fvec4) Load 39(input)
+ Store 152(param) 153
+ 154: 8(float) FunctionCall 20(f3(vf4;) 152(param)
+ 156: 9(fvec4) Load 39(input)
+ Store 155(param) 156
+ 157: 8(float) FunctionCall 23(f4(vf4;) 155(param)
+ 159: 9(fvec4) Load 39(input)
+ Store 158(param) 159
+ 160: 2 FunctionCall 26(f5(vf4;) 158(param)
+ 162: 9(fvec4) Load 39(input)
+ Store 161(param) 162
+ 163: 2 FunctionCall 29(f6(vf4;) 161(param)
+ Store 164(ii) 165
+ Branch 166
+ 166: Label
+ LoopMerge 168 169 None
Branch 170
170: Label
- Branch 172
- 172: Label
- Branch 169
- 171: Label
- 173: 7(fvec4) Undef
- ReturnValue 173
+ 171: 122(int) Load 164(ii)
+ 173: 61(bool) SLessThan 171 172
+ BranchConditional 173 167 168
+ 167: Label
+ 174: 122(int) Load 164(ii)
+ 176: 61(bool) IEqual 174 175
+ SelectionMerge 178 None
+ BranchConditional 176 177 178
+ 177: Label
+ Branch 169
+ 178: Label
+ Branch 169
+ 169: Label
+ 180: 122(int) Load 164(ii)
+ 181: 122(int) IAdd 180 127
+ Store 164(ii) 181
+ Branch 166
+ 168: Label
+ 183: 8(float) Load 182(ii)
+ 184: 8(float) FSub 183 47
+ Store 182(ii) 184
+ 185: 2 FunctionCall 31(f99()
+ Store 186(i) 125
+ 188: 8(float) Load 182(ii)
+ 189: 122(int) ConvertFToS 188
+ Store 187(count) 189
+ Branch 190
+ 190: Label
+ LoopMerge 192 193 None
+ Branch 194
+ 194: Label
+ 195: 122(int) Load 186(i)
+ 196: 122(int) Load 187(count)
+ 197: 61(bool) SLessThan 195 196
+ BranchConditional 197 191 192
+ 191: Label
+ Branch 193
+ 193: Label
+ 198: 122(int) Load 186(i)
+ 199: 122(int) IAdd 198 127
+ Store 186(i) 199
+ Branch 190
+ 192: Label
+ Store 200(first) 201
+ Branch 202
+ 202: Label
+ LoopMerge 204 205 None
+ Branch 206
+ 206: Label
+ 207: 8(float) Load 200(first)
+ 212: 33(ptr) AccessChain 211(second) 125
+ 213: 8(float) Load 212
+ 214: 61(bool) FOrdLessThan 207 213
+ BranchConditional 214 203 204
+ 203: Label
+ 215: 8(float) Load 200(first)
+ 216: 33(ptr) AccessChain 211(second) 127
+ 217: 8(float) Load 216
+ 218: 8(float) FAdd 215 217
+ 220: 8(float) Load 219(third)
+ 221: 8(float) FAdd 218 220
+ Branch 205
+ 205: Label
+ 222: 33(ptr) AccessChain 211(second) 127
+ 223: 8(float) Load 222
+ 224: 8(float) FAdd 223 47
+ Store 222 224
+ Branch 202
+ 204: Label
+ 226: 8(float) Load 182(ii)
+ Store 225(param) 226
+ 227: 2 FunctionCall 36(f100(f1;) 225(param)
+ 228: 9(fvec4) Load 39(input)
+ ReturnValue 228
FunctionEnd
diff --git a/Test/baseResults/hlsl.if.frag.out b/Test/baseResults/hlsl.if.frag.out
index 056b672..255345a 100644
--- a/Test/baseResults/hlsl.if.frag.out
+++ b/Test/baseResults/hlsl.if.frag.out
@@ -2,104 +2,116 @@
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
-0:2 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
-0:2 Function Parameters:
-0:2 'input' ( in 4-component vector of float)
+0:1 Function Definition: f0(vf4; ( temp 4-component vector of float)
+0:1 Function Parameters:
+0:1 'input' ( in 4-component vector of float)
0:? Sequence
-0:3 Test condition and select ( temp void)
-0:3 Condition
-0:3 all ( temp bool)
-0:3 Equal ( temp 4-component vector of bool)
-0:3 'input' ( in 4-component vector of float)
-0:3 'input' ( in 4-component vector of float)
-0:3 true case
-0:4 Branch: Return with expression
-0:4 'input' ( in 4-component vector of float)
-0:6 Test condition and select ( temp void)
-0:6 Condition
-0:6 all ( temp bool)
-0:6 Equal ( temp 4-component vector of bool)
-0:6 'input' ( in 4-component vector of float)
-0:6 'input' ( in 4-component vector of float)
-0:6 true case
-0:7 Branch: Return with expression
-0:7 'input' ( in 4-component vector of float)
-0:6 false case
-0:9 Branch: Return with expression
-0:9 Negate value ( temp 4-component vector of float)
+0:2 Test condition and select ( temp void)
+0:2 Condition
+0:2 all ( temp bool)
+0:2 Equal ( temp 4-component vector of bool)
+0:2 'input' ( in 4-component vector of float)
+0:2 'input' ( in 4-component vector of float)
+0:2 true case
+0:3 Branch: Return with expression
+0:3 'input' ( in 4-component vector of float)
+0:2 false case
+0:5 Branch: Return with expression
+0:5 Negate value ( temp 4-component vector of float)
+0:5 'input' ( in 4-component vector of float)
+0:8 Function Definition: f1(vf4; ( temp 4-component vector of float)
+0:8 Function Parameters:
+0:8 'input' ( in 4-component vector of float)
+0:? Sequence
+0:9 Test condition and select ( temp void)
+0:9 Condition
+0:9 all ( temp bool)
+0:9 Equal ( temp 4-component vector of bool)
0:9 'input' ( in 4-component vector of float)
-0:11 Test condition and select ( temp void)
-0:11 Condition
-0:11 all ( temp bool)
-0:11 Equal ( temp 4-component vector of bool)
-0:11 'input' ( in 4-component vector of float)
-0:11 'input' ( in 4-component vector of float)
-0:11 true case is null
-0:14 Test condition and select ( temp void)
-0:14 Condition
-0:14 all ( temp bool)
-0:14 Equal ( temp 4-component vector of bool)
-0:14 'input' ( in 4-component vector of float)
-0:14 'input' ( in 4-component vector of float)
-0:14 true case is null
-0:19 Test condition and select ( temp void): Flatten
-0:19 Condition
-0:19 all ( temp bool)
-0:19 Equal ( temp 4-component vector of bool)
-0:19 'input' ( in 4-component vector of float)
-0:19 'input' ( in 4-component vector of float)
-0:19 true case
+0:9 'input' ( in 4-component vector of float)
+0:9 true case
0:? Sequence
-0:20 Branch: Return with expression
-0:20 'input' ( in 4-component vector of float)
+0:10 Branch: Return with expression
+0:10 'input' ( in 4-component vector of float)
+0:9 false case
+0:? Sequence
+0:12 Branch: Return with expression
+0:12 Negate value ( temp 4-component vector of float)
+0:12 'input' ( in 4-component vector of float)
+0:17 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:17 Function Parameters:
+0:17 'input' ( in 4-component vector of float)
+0:? Sequence
+0:18 Test condition and select ( temp void)
+0:18 Condition
+0:18 all ( temp bool)
+0:18 Equal ( temp 4-component vector of bool)
+0:18 'input' ( in 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 true case
+0:19 Branch: Return with expression
+0:19 'input' ( in 4-component vector of float)
+0:21 Function Call: f0(vf4; ( temp 4-component vector of float)
+0:21 'input' ( in 4-component vector of float)
0:23 Test condition and select ( temp void)
0:23 Condition
0:23 all ( temp bool)
0:23 Equal ( temp 4-component vector of bool)
0:23 'input' ( in 4-component vector of float)
0:23 'input' ( in 4-component vector of float)
-0:23 true case
+0:23 true case is null
+0:26 Test condition and select ( temp void)
+0:26 Condition
+0:26 all ( temp bool)
+0:26 Equal ( temp 4-component vector of bool)
+0:26 'input' ( in 4-component vector of float)
+0:26 'input' ( in 4-component vector of float)
+0:26 true case is null
+0:31 Test condition and select ( temp void): Flatten
+0:31 Condition
+0:31 all ( temp bool)
+0:31 Equal ( temp 4-component vector of bool)
+0:31 'input' ( in 4-component vector of float)
+0:31 'input' ( in 4-component vector of float)
+0:31 true case
0:? Sequence
-0:24 Branch: Return with expression
-0:24 'input' ( in 4-component vector of float)
-0:23 false case
-0:? Sequence
-0:26 Branch: Return with expression
-0:26 Negate value ( temp 4-component vector of float)
-0:26 'input' ( in 4-component vector of float)
-0:30 Test condition and select ( temp void)
-0:30 Condition
-0:30 Convert float to bool ( temp bool)
-0:30 move second child to first child ( temp float)
-0:30 'ii' ( temp float)
-0:30 direct index ( temp float)
-0:30 'input' ( in 4-component vector of float)
-0:30 Constant:
-0:30 2 (const int)
-0:30 true case
-0:31 Pre-Increment ( temp float)
-0:31 'ii' ( temp float)
-0:32 Pre-Increment ( temp int)
-0:32 'ii' ( temp int)
-0:33 Test condition and select ( temp void)
-0:33 Condition
-0:33 Compare Equal ( temp bool)
-0:33 Convert int to float ( temp float)
-0:33 'ii' ( temp int)
-0:33 Constant:
-0:33 1.000000
-0:33 true case
-0:34 Pre-Increment ( temp int)
-0:34 'ii' ( temp int)
-0:2 Function Definition: PixelShaderFunction( ( temp void)
-0:2 Function Parameters:
+0:32 Branch: Return with expression
+0:32 'input' ( in 4-component vector of float)
+0:35 Function Call: f1(vf4; ( temp 4-component vector of float)
+0:35 'input' ( in 4-component vector of float)
+0:38 Test condition and select ( temp void)
+0:38 Condition
+0:38 Convert float to bool ( temp bool)
+0:38 move second child to first child ( temp float)
+0:38 'ii' ( temp float)
+0:38 direct index ( temp float)
+0:38 'input' ( in 4-component vector of float)
+0:38 Constant:
+0:38 2 (const int)
+0:38 true case
+0:39 Pre-Increment ( temp float)
+0:39 'ii' ( temp float)
+0:40 Pre-Increment ( temp int)
+0:40 'ii' ( temp int)
+0:41 Test condition and select ( temp void)
+0:41 Condition
+0:41 Compare Equal ( temp bool)
+0:41 Convert int to float ( temp float)
+0:41 'ii' ( temp int)
+0:41 Constant:
+0:41 1.000000
+0:41 true case
+0:42 Pre-Increment ( temp int)
+0:42 'ii' ( temp int)
+0:17 Function Definition: PixelShaderFunction( ( temp void)
+0:17 Function Parameters:
0:? Sequence
-0:2 move second child to first child ( temp 4-component vector of float)
+0:17 move second child to first child ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? 'input' (layout( location=0) in 4-component vector of float)
-0:2 move second child to first child ( temp 4-component vector of float)
+0:17 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
-0:2 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:17 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@@ -112,104 +124,116 @@
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
-0:2 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
-0:2 Function Parameters:
-0:2 'input' ( in 4-component vector of float)
+0:1 Function Definition: f0(vf4; ( temp 4-component vector of float)
+0:1 Function Parameters:
+0:1 'input' ( in 4-component vector of float)
0:? Sequence
-0:3 Test condition and select ( temp void)
-0:3 Condition
-0:3 all ( temp bool)
-0:3 Equal ( temp 4-component vector of bool)
-0:3 'input' ( in 4-component vector of float)
-0:3 'input' ( in 4-component vector of float)
-0:3 true case
-0:4 Branch: Return with expression
-0:4 'input' ( in 4-component vector of float)
-0:6 Test condition and select ( temp void)
-0:6 Condition
-0:6 all ( temp bool)
-0:6 Equal ( temp 4-component vector of bool)
-0:6 'input' ( in 4-component vector of float)
-0:6 'input' ( in 4-component vector of float)
-0:6 true case
-0:7 Branch: Return with expression
-0:7 'input' ( in 4-component vector of float)
-0:6 false case
-0:9 Branch: Return with expression
-0:9 Negate value ( temp 4-component vector of float)
+0:2 Test condition and select ( temp void)
+0:2 Condition
+0:2 all ( temp bool)
+0:2 Equal ( temp 4-component vector of bool)
+0:2 'input' ( in 4-component vector of float)
+0:2 'input' ( in 4-component vector of float)
+0:2 true case
+0:3 Branch: Return with expression
+0:3 'input' ( in 4-component vector of float)
+0:2 false case
+0:5 Branch: Return with expression
+0:5 Negate value ( temp 4-component vector of float)
+0:5 'input' ( in 4-component vector of float)
+0:8 Function Definition: f1(vf4; ( temp 4-component vector of float)
+0:8 Function Parameters:
+0:8 'input' ( in 4-component vector of float)
+0:? Sequence
+0:9 Test condition and select ( temp void)
+0:9 Condition
+0:9 all ( temp bool)
+0:9 Equal ( temp 4-component vector of bool)
0:9 'input' ( in 4-component vector of float)
-0:11 Test condition and select ( temp void)
-0:11 Condition
-0:11 all ( temp bool)
-0:11 Equal ( temp 4-component vector of bool)
-0:11 'input' ( in 4-component vector of float)
-0:11 'input' ( in 4-component vector of float)
-0:11 true case is null
-0:14 Test condition and select ( temp void)
-0:14 Condition
-0:14 all ( temp bool)
-0:14 Equal ( temp 4-component vector of bool)
-0:14 'input' ( in 4-component vector of float)
-0:14 'input' ( in 4-component vector of float)
-0:14 true case is null
-0:19 Test condition and select ( temp void): Flatten
-0:19 Condition
-0:19 all ( temp bool)
-0:19 Equal ( temp 4-component vector of bool)
-0:19 'input' ( in 4-component vector of float)
-0:19 'input' ( in 4-component vector of float)
-0:19 true case
+0:9 'input' ( in 4-component vector of float)
+0:9 true case
0:? Sequence
-0:20 Branch: Return with expression
-0:20 'input' ( in 4-component vector of float)
+0:10 Branch: Return with expression
+0:10 'input' ( in 4-component vector of float)
+0:9 false case
+0:? Sequence
+0:12 Branch: Return with expression
+0:12 Negate value ( temp 4-component vector of float)
+0:12 'input' ( in 4-component vector of float)
+0:17 Function Definition: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:17 Function Parameters:
+0:17 'input' ( in 4-component vector of float)
+0:? Sequence
+0:18 Test condition and select ( temp void)
+0:18 Condition
+0:18 all ( temp bool)
+0:18 Equal ( temp 4-component vector of bool)
+0:18 'input' ( in 4-component vector of float)
+0:18 'input' ( in 4-component vector of float)
+0:18 true case
+0:19 Branch: Return with expression
+0:19 'input' ( in 4-component vector of float)
+0:21 Function Call: f0(vf4; ( temp 4-component vector of float)
+0:21 'input' ( in 4-component vector of float)
0:23 Test condition and select ( temp void)
0:23 Condition
0:23 all ( temp bool)
0:23 Equal ( temp 4-component vector of bool)
0:23 'input' ( in 4-component vector of float)
0:23 'input' ( in 4-component vector of float)
-0:23 true case
+0:23 true case is null
+0:26 Test condition and select ( temp void)
+0:26 Condition
+0:26 all ( temp bool)
+0:26 Equal ( temp 4-component vector of bool)
+0:26 'input' ( in 4-component vector of float)
+0:26 'input' ( in 4-component vector of float)
+0:26 true case is null
+0:31 Test condition and select ( temp void): Flatten
+0:31 Condition
+0:31 all ( temp bool)
+0:31 Equal ( temp 4-component vector of bool)
+0:31 'input' ( in 4-component vector of float)
+0:31 'input' ( in 4-component vector of float)
+0:31 true case
0:? Sequence
-0:24 Branch: Return with expression
-0:24 'input' ( in 4-component vector of float)
-0:23 false case
-0:? Sequence
-0:26 Branch: Return with expression
-0:26 Negate value ( temp 4-component vector of float)
-0:26 'input' ( in 4-component vector of float)
-0:30 Test condition and select ( temp void)
-0:30 Condition
-0:30 Convert float to bool ( temp bool)
-0:30 move second child to first child ( temp float)
-0:30 'ii' ( temp float)
-0:30 direct index ( temp float)
-0:30 'input' ( in 4-component vector of float)
-0:30 Constant:
-0:30 2 (const int)
-0:30 true case
-0:31 Pre-Increment ( temp float)
-0:31 'ii' ( temp float)
-0:32 Pre-Increment ( temp int)
-0:32 'ii' ( temp int)
-0:33 Test condition and select ( temp void)
-0:33 Condition
-0:33 Compare Equal ( temp bool)
-0:33 Convert int to float ( temp float)
-0:33 'ii' ( temp int)
-0:33 Constant:
-0:33 1.000000
-0:33 true case
-0:34 Pre-Increment ( temp int)
-0:34 'ii' ( temp int)
-0:2 Function Definition: PixelShaderFunction( ( temp void)
-0:2 Function Parameters:
+0:32 Branch: Return with expression
+0:32 'input' ( in 4-component vector of float)
+0:35 Function Call: f1(vf4; ( temp 4-component vector of float)
+0:35 'input' ( in 4-component vector of float)
+0:38 Test condition and select ( temp void)
+0:38 Condition
+0:38 Convert float to bool ( temp bool)
+0:38 move second child to first child ( temp float)
+0:38 'ii' ( temp float)
+0:38 direct index ( temp float)
+0:38 'input' ( in 4-component vector of float)
+0:38 Constant:
+0:38 2 (const int)
+0:38 true case
+0:39 Pre-Increment ( temp float)
+0:39 'ii' ( temp float)
+0:40 Pre-Increment ( temp int)
+0:40 'ii' ( temp int)
+0:41 Test condition and select ( temp void)
+0:41 Condition
+0:41 Compare Equal ( temp bool)
+0:41 Convert int to float ( temp float)
+0:41 'ii' ( temp int)
+0:41 Constant:
+0:41 1.000000
+0:41 true case
+0:42 Pre-Increment ( temp int)
+0:42 'ii' ( temp int)
+0:17 Function Definition: PixelShaderFunction( ( temp void)
+0:17 Function Parameters:
0:? Sequence
-0:2 move second child to first child ( temp 4-component vector of float)
+0:17 move second child to first child ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? 'input' (layout( location=0) in 4-component vector of float)
-0:2 move second child to first child ( temp 4-component vector of float)
+0:17 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
-0:2 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
+0:17 Function Call: @PixelShaderFunction(vf4; ( temp 4-component vector of float)
0:? 'input' ( temp 4-component vector of float)
0:? Linker Objects
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
@@ -217,154 +241,178 @@
// Module Version 10000
// Generated by (magic number): 80007
-// Id's are bound by 103
+// Id's are bound by 117
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Fragment 4 "PixelShaderFunction" 96 99
+ EntryPoint Fragment 4 "PixelShaderFunction" 110 113
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "PixelShaderFunction"
- Name 11 "@PixelShaderFunction(vf4;"
+ Name 11 "f0(vf4;"
Name 10 "input"
- Name 68 "ii"
+ Name 14 "f1(vf4;"
+ Name 13 "input"
+ Name 17 "@PixelShaderFunction(vf4;"
+ Name 16 "input"
+ Name 55 "param"
+ Name 78 "param"
Name 82 "ii"
- Name 94 "input"
- Name 96 "input"
- Name 99 "@entryPointOutput"
- Name 100 "param"
- Decorate 96(input) Location 0
- Decorate 99(@entryPointOutput) Location 0
+ Name 96 "ii"
+ Name 108 "input"
+ Name 110 "input"
+ Name 113 "@entryPointOutput"
+ Name 114 "param"
+ Decorate 110(input) Location 0
+ Decorate 113(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
9: TypeFunction 7(fvec4) 8(ptr)
- 15: TypeBool
- 16: TypeVector 15(bool) 4
- 67: TypePointer Function 6(float)
- 69: TypeInt 32 0
- 70: 69(int) Constant 2
- 73: 6(float) Constant 0
- 78: 6(float) Constant 1065353216
- 80: TypeInt 32 1
- 81: TypePointer Function 80(int)
- 84: 80(int) Constant 1
- 95: TypePointer Input 7(fvec4)
- 96(input): 95(ptr) Variable Input
- 98: TypePointer Output 7(fvec4)
-99(@entryPointOutput): 98(ptr) Variable Output
+ 21: TypeBool
+ 22: TypeVector 21(bool) 4
+ 81: TypePointer Function 6(float)
+ 83: TypeInt 32 0
+ 84: 83(int) Constant 2
+ 87: 6(float) Constant 0
+ 92: 6(float) Constant 1065353216
+ 94: TypeInt 32 1
+ 95: TypePointer Function 94(int)
+ 98: 94(int) Constant 1
+ 109: TypePointer Input 7(fvec4)
+ 110(input): 109(ptr) Variable Input
+ 112: TypePointer Output 7(fvec4)
+113(@entryPointOutput): 112(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3
5: Label
- 94(input): 8(ptr) Variable Function
- 100(param): 8(ptr) Variable Function
- 97: 7(fvec4) Load 96(input)
- Store 94(input) 97
- 101: 7(fvec4) Load 94(input)
- Store 100(param) 101
- 102: 7(fvec4) FunctionCall 11(@PixelShaderFunction(vf4;) 100(param)
- Store 99(@entryPointOutput) 102
+ 108(input): 8(ptr) Variable Function
+ 114(param): 8(ptr) Variable Function
+ 111: 7(fvec4) Load 110(input)
+ Store 108(input) 111
+ 115: 7(fvec4) Load 108(input)
+ Store 114(param) 115
+ 116: 7(fvec4) FunctionCall 17(@PixelShaderFunction(vf4;) 114(param)
+ Store 113(@entryPointOutput) 116
Return
FunctionEnd
-11(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9
+ 11(f0(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter
12: Label
- 68(ii): 67(ptr) Variable Function
+ 19: 7(fvec4) Load 10(input)
+ 20: 7(fvec4) Load 10(input)
+ 23: 22(bvec4) FOrdEqual 19 20
+ 24: 21(bool) All 23
+ SelectionMerge 26 None
+ BranchConditional 24 25 29
+ 25: Label
+ 27: 7(fvec4) Load 10(input)
+ ReturnValue 27
+ 29: Label
+ 30: 7(fvec4) Load 10(input)
+ 31: 7(fvec4) FNegate 30
+ ReturnValue 31
+ 26: Label
+ Unreachable
+ FunctionEnd
+ 14(f1(vf4;): 7(fvec4) Function None 9
+ 13(input): 8(ptr) FunctionParameter
+ 15: Label
+ 34: 7(fvec4) Load 13(input)
+ 35: 7(fvec4) Load 13(input)
+ 36: 22(bvec4) FOrdEqual 34 35
+ 37: 21(bool) All 36
+ SelectionMerge 39 None
+ BranchConditional 37 38 42
+ 38: Label
+ 40: 7(fvec4) Load 13(input)
+ ReturnValue 40
+ 42: Label
+ 43: 7(fvec4) Load 13(input)
+ 44: 7(fvec4) FNegate 43
+ ReturnValue 44
+ 39: Label
+ Unreachable
+ FunctionEnd
+17(@PixelShaderFunction(vf4;): 7(fvec4) Function None 9
+ 16(input): 8(ptr) FunctionParameter
+ 18: Label
+ 55(param): 8(ptr) Variable Function
+ 78(param): 8(ptr) Variable Function
82(ii): 81(ptr) Variable Function
- 13: 7(fvec4) Load 10(input)
- 14: 7(fvec4) Load 10(input)
- 17: 16(bvec4) FOrdEqual 13 14
- 18: 15(bool) All 17
- SelectionMerge 20 None
- BranchConditional 18 19 20
- 19: Label
- 21: 7(fvec4) Load 10(input)
- ReturnValue 21
- 20: Label
- 23: 7(fvec4) Load 10(input)
- 24: 7(fvec4) Load 10(input)
- 25: 16(bvec4) FOrdEqual 23 24
- 26: 15(bool) All 25
- SelectionMerge 28 None
- BranchConditional 26 27 31
- 27: Label
- 29: 7(fvec4) Load 10(input)
- ReturnValue 29
- 31: Label
- 32: 7(fvec4) Load 10(input)
- 33: 7(fvec4) FNegate 32
- ReturnValue 33
- 28: Label
- 35: 7(fvec4) Load 10(input)
- 36: 7(fvec4) Load 10(input)
- 37: 16(bvec4) FOrdEqual 35 36
- 38: 15(bool) All 37
- SelectionMerge 40 None
- BranchConditional 38 39 40
- 39: Label
- Branch 40
- 40: Label
- 41: 7(fvec4) Load 10(input)
- 42: 7(fvec4) Load 10(input)
- 43: 16(bvec4) FOrdEqual 41 42
- 44: 15(bool) All 43
- SelectionMerge 46 None
- BranchConditional 44 45 46
- 45: Label
- Branch 46
- 46: Label
- 47: 7(fvec4) Load 10(input)
- 48: 7(fvec4) Load 10(input)
- 49: 16(bvec4) FOrdEqual 47 48
- 50: 15(bool) All 49
- SelectionMerge 52 Flatten
+ 96(ii): 95(ptr) Variable Function
+ 47: 7(fvec4) Load 16(input)
+ 48: 7(fvec4) Load 16(input)
+ 49: 22(bvec4) FOrdEqual 47 48
+ 50: 21(bool) All 49
+ SelectionMerge 52 None
BranchConditional 50 51 52
51: Label
- 53: 7(fvec4) Load 10(input)
+ 53: 7(fvec4) Load 16(input)
ReturnValue 53
52: Label
- 55: 7(fvec4) Load 10(input)
- 56: 7(fvec4) Load 10(input)
- 57: 16(bvec4) FOrdEqual 55 56
- 58: 15(bool) All 57
- SelectionMerge 60 None
- BranchConditional 58 59 63
- 59: Label
- 61: 7(fvec4) Load 10(input)
- ReturnValue 61
- 63: Label
- 64: 7(fvec4) Load 10(input)
- 65: 7(fvec4) FNegate 64
- ReturnValue 65
- 60: Label
- 71: 67(ptr) AccessChain 10(input) 70
- 72: 6(float) Load 71
- Store 68(ii) 72
- 74: 15(bool) FOrdNotEqual 72 73
- SelectionMerge 76 None
- BranchConditional 74 75 76
- 75: Label
- 77: 6(float) Load 68(ii)
- 79: 6(float) FAdd 77 78
- Store 68(ii) 79
- Branch 76
- 76: Label
- 83: 80(int) Load 82(ii)
- 85: 80(int) IAdd 83 84
- Store 82(ii) 85
- 86: 80(int) Load 82(ii)
- 87: 6(float) ConvertSToF 86
- 88: 15(bool) FOrdEqual 87 78
+ 56: 7(fvec4) Load 16(input)
+ Store 55(param) 56
+ 57: 7(fvec4) FunctionCall 11(f0(vf4;) 55(param)
+ 58: 7(fvec4) Load 16(input)
+ 59: 7(fvec4) Load 16(input)
+ 60: 22(bvec4) FOrdEqual 58 59
+ 61: 21(bool) All 60
+ SelectionMerge 63 None
+ BranchConditional 61 62 63
+ 62: Label
+ Branch 63
+ 63: Label
+ 64: 7(fvec4) Load 16(input)
+ 65: 7(fvec4) Load 16(input)
+ 66: 22(bvec4) FOrdEqual 64 65
+ 67: 21(bool) All 66
+ SelectionMerge 69 None
+ BranchConditional 67 68 69
+ 68: Label
+ Branch 69
+ 69: Label
+ 70: 7(fvec4) Load 16(input)
+ 71: 7(fvec4) Load 16(input)
+ 72: 22(bvec4) FOrdEqual 70 71
+ 73: 21(bool) All 72
+ SelectionMerge 75 Flatten
+ BranchConditional 73 74 75
+ 74: Label
+ 76: 7(fvec4) Load 16(input)
+ ReturnValue 76
+ 75: Label
+ 79: 7(fvec4) Load 16(input)
+ Store 78(param) 79
+ 80: 7(fvec4) FunctionCall 14(f1(vf4;) 78(param)
+ 85: 81(ptr) AccessChain 16(input) 84
+ 86: 6(float) Load 85
+ Store 82(ii) 86
+ 88: 21(bool) FOrdNotEqual 86 87
SelectionMerge 90 None
BranchConditional 88 89 90
89: Label
- 91: 80(int) Load 82(ii)
- 92: 80(int) IAdd 91 84
- Store 82(ii) 92
+ 91: 6(float) Load 82(ii)
+ 93: 6(float) FAdd 91 92
+ Store 82(ii) 93
Branch 90
90: Label
- 93: 7(fvec4) Undef
- ReturnValue 93
+ 97: 94(int) Load 96(ii)
+ 99: 94(int) IAdd 97 98
+ Store 96(ii) 99
+ 100: 94(int) Load 96(ii)
+ 101: 6(float) ConvertSToF 100
+ 102: 21(bool) FOrdEqual 101 92
+ SelectionMerge 104 None
+ BranchConditional 102 103 104
+ 103: Label
+ 105: 94(int) Load 96(ii)
+ 106: 94(int) IAdd 105 98
+ Store 96(ii) 106
+ Branch 104
+ 104: Label
+ 107: 7(fvec4) Undef
+ ReturnValue 107
FunctionEnd
diff --git a/Test/baseResults/hlsl.structbuffer.coherent.frag.out b/Test/baseResults/hlsl.structbuffer.coherent.frag.out
index b33b44d..96f1b97 100644
--- a/Test/baseResults/hlsl.structbuffer.coherent.frag.out
+++ b/Test/baseResults/hlsl.structbuffer.coherent.frag.out
@@ -305,6 +305,5 @@
66: 9(fvec4) CompositeConstruct 65 65 65 65
ReturnValue 66
45: Label
- 68: 9(fvec4) Undef
- ReturnValue 68
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/hlsl.structbuffer.frag.out b/Test/baseResults/hlsl.structbuffer.frag.out
index 9a67fd7..046c74d 100644
--- a/Test/baseResults/hlsl.structbuffer.frag.out
+++ b/Test/baseResults/hlsl.structbuffer.frag.out
@@ -344,6 +344,5 @@
84: 9(fvec4) CompositeConstruct 83 83 83 83
ReturnValue 84
53: Label
- 86: 9(fvec4) Undef
- ReturnValue 86
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/hlsl.structbuffer.rw.frag.out b/Test/baseResults/hlsl.structbuffer.rw.frag.out
index ceccd5b..49ba89e 100644
--- a/Test/baseResults/hlsl.structbuffer.rw.frag.out
+++ b/Test/baseResults/hlsl.structbuffer.rw.frag.out
@@ -303,6 +303,5 @@
66: 9(fvec4) CompositeConstruct 65 65 65 65
ReturnValue 66
45: Label
- 68: 9(fvec4) Undef
- ReturnValue 68
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/hlsl.wavequery.frag.out b/Test/baseResults/hlsl.wavequery.frag.out
index 52304a6..3d446ed 100644
--- a/Test/baseResults/hlsl.wavequery.frag.out
+++ b/Test/baseResults/hlsl.wavequery.frag.out
@@ -118,6 +118,5 @@
23: Label
ReturnValue 24
16: Label
- 26: 7(fvec4) Undef
- ReturnValue 26
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/remap.similar_1a.everything.frag.out b/Test/baseResults/remap.similar_1a.everything.frag.out
index 2f8f1c7..17efb93 100644
--- a/Test/baseResults/remap.similar_1a.everything.frag.out
+++ b/Test/baseResults/remap.similar_1a.everything.frag.out
@@ -88,7 +88,7 @@
22102: 649(ptr) Variable Function
24151: 12(int) Load 4408
13868: 9(bool) SGreaterThan 24151 2577
- SelectionMerge 22309 None
+ SelectionMerge 14966 None
BranchConditional 13868 9492 17416
9492: Label
15624: 12(int) Load 4408
@@ -109,7 +109,6 @@
10505: 12(int) IAdd 11462 21176
14626: 13(float) ConvertSToF 10505
ReturnValue 14626
- 22309: Label
- 6429: 13(float) Undef
- ReturnValue 6429
+ 14966: Label
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/remap.similar_1a.none.frag.out b/Test/baseResults/remap.similar_1a.none.frag.out
index 80d35c3..57c71ac 100644
--- a/Test/baseResults/remap.similar_1a.none.frag.out
+++ b/Test/baseResults/remap.similar_1a.none.frag.out
@@ -124,6 +124,5 @@
68: 8(float) ConvertSToF 67
ReturnValue 68
43: Label
- 70: 8(float) Undef
- ReturnValue 70
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/remap.similar_1b.everything.frag.out b/Test/baseResults/remap.similar_1b.everything.frag.out
index c76c4bf..4783d89 100644
--- a/Test/baseResults/remap.similar_1b.everything.frag.out
+++ b/Test/baseResults/remap.similar_1b.everything.frag.out
@@ -93,7 +93,7 @@
22102: 649(ptr) Variable Function
24151: 12(int) Load 4408
13868: 9(bool) SGreaterThan 24151 2577
- SelectionMerge 22309 None
+ SelectionMerge 14966 None
BranchConditional 13868 10822 17416
10822: Label
22680: 12(int) Load 4408
@@ -115,7 +115,6 @@
10505: 12(int) IAdd 11462 21176
14626: 13(float) ConvertSToF 10505
ReturnValue 14626
- 22309: Label
- 6429: 13(float) Undef
- ReturnValue 6429
+ 14966: Label
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/remap.similar_1b.none.frag.out b/Test/baseResults/remap.similar_1b.none.frag.out
index 0a854d6..08d0919 100644
--- a/Test/baseResults/remap.similar_1b.none.frag.out
+++ b/Test/baseResults/remap.similar_1b.none.frag.out
@@ -130,6 +130,5 @@
73: 8(float) ConvertSToF 72
ReturnValue 73
46: Label
- 75: 8(float) Undef
- ReturnValue 75
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/spv.controlFlowAttributes.frag.out b/Test/baseResults/spv.controlFlowAttributes.frag.out
index c708232..c424b74 100644
--- a/Test/baseResults/spv.controlFlowAttributes.frag.out
+++ b/Test/baseResults/spv.controlFlowAttributes.frag.out
@@ -1,16 +1,16 @@
spv.controlFlowAttributes.frag
-WARNING: 0:20: 'unroll' : expected no arguments
-WARNING: 0:21: 'dont_unroll' : expected no arguments
-WARNING: 0:22: 'dependency_infinite' : expected no arguments
-WARNING: 0:23: 'dependency_length' : expected a single integer argument
-WARNING: 0:24: '' : attribute with arguments not recognized, skipping
-WARNING: 0:25: '' : attribute with arguments not recognized, skipping
-WARNING: 0:26: '' : attribute with arguments not recognized, skipping
+WARNING: 0:27: 'unroll' : expected no arguments
+WARNING: 0:28: 'dont_unroll' : expected no arguments
+WARNING: 0:29: 'dependency_infinite' : expected no arguments
+WARNING: 0:30: 'dependency_length' : expected a single integer argument
+WARNING: 0:31: '' : attribute with arguments not recognized, skipping
+WARNING: 0:32: '' : attribute with arguments not recognized, skipping
+WARNING: 0:33: '' : attribute with arguments not recognized, skipping
Validation failed
// Module Version 10000
// Generated by (magic number): 80007
-// Id's are bound by 118
+// Id's are bound by 123
Capability Shader
1: ExtInstImport "GLSL.std.450"
@@ -20,220 +20,231 @@
Source GLSL 450
SourceExtension "GL_EXT_control_flow_attributes"
Name 4 "main"
- Name 8 "i"
- Name 36 "i"
- Name 47 "cond"
- Name 60 "i"
- Name 79 "i"
+ Name 6 "f0("
+ Name 8 "f1("
+ Name 23 "i"
+ Name 41 "i"
+ Name 52 "cond"
+ Name 65 "i"
+ Name 84 "i"
2: TypeVoid
3: TypeFunction 2
- 6: TypeInt 32 1
- 7: TypePointer Function 6(int)
- 9: 6(int) Constant 0
- 16: 6(int) Constant 8
- 17: TypeBool
- 20: 6(int) Constant 1
- 31: 17(bool) ConstantTrue
- 46: TypePointer Private 17(bool)
- 47(cond): 46(ptr) Variable Private
- 54: 17(bool) ConstantFalse
- 55: 6(int) Constant 3
+ 19: TypeBool
+ 20: 19(bool) ConstantTrue
+ 21: TypeInt 32 1
+ 22: TypePointer Function 21(int)
+ 24: 21(int) Constant 0
+ 31: 21(int) Constant 8
+ 34: 21(int) Constant 1
+ 51: TypePointer Private 19(bool)
+ 52(cond): 51(ptr) Variable Private
+ 59: 19(bool) ConstantFalse
+ 60: 21(int) Constant 3
4(main): 2 Function None 3
5: Label
- 8(i): 7(ptr) Variable Function
- 36(i): 7(ptr) Variable Function
- 60(i): 7(ptr) Variable Function
- 79(i): 7(ptr) Variable Function
- Store 8(i) 9
- Branch 10
- 10: Label
- LoopMerge 12 13 Unroll
- Branch 14
- 14: Label
- 15: 6(int) Load 8(i)
- 18: 17(bool) SLessThan 15 16
- BranchConditional 18 11 12
- 11: Label
- Branch 13
- 13: Label
- 19: 6(int) Load 8(i)
- 21: 6(int) IAdd 19 20
- Store 8(i) 21
- Branch 10
- 12: Label
- Branch 22
- 22: Label
- LoopMerge 24 25 DontUnroll
- Branch 23
- 23: Label
+ 23(i): 22(ptr) Variable Function
+ 41(i): 22(ptr) Variable Function
+ 65(i): 22(ptr) Variable Function
+ 84(i): 22(ptr) Variable Function
+ Store 23(i) 24
Branch 25
25: Label
- Branch 22
- 24: Label
- Branch 26
- 26: Label
- LoopMerge 28 29 DontUnroll
- Branch 30
- 30: Label
- BranchConditional 31 27 28
- 27: Label
- Branch 29
- 29: Label
- Branch 26
- 28: Label
- Branch 32
- 32: Label
- LoopMerge 34 35 DependencyInfinite
- Branch 33
- 33: Label
- Branch 35
- 35: Label
- BranchConditional 31 32 34
- 34: Label
- Store 36(i) 9
+ LoopMerge 27 28 Unroll
+ Branch 29
+ 29: Label
+ 30: 21(int) Load 23(i)
+ 32: 19(bool) SLessThan 30 31
+ BranchConditional 32 26 27
+ 26: Label
+ Branch 28
+ 28: Label
+ 33: 21(int) Load 23(i)
+ 35: 21(int) IAdd 33 34
+ Store 23(i) 35
+ Branch 25
+ 27: Label
+ 36: 2 FunctionCall 6(f0()
Branch 37
37: Label
- LoopMerge 39 40 DependencyLength 4
- Branch 41
- 41: Label
- 42: 6(int) Load 36(i)
- 43: 17(bool) SLessThan 42 16
- BranchConditional 43 38 39
- 38: Label
- Branch 40
- 40: Label
- 44: 6(int) Load 36(i)
- 45: 6(int) IAdd 44 20
- Store 36(i) 45
- Branch 37
+ LoopMerge 39 40 DependencyInfinite
+ Branch 38
+ 38: Label
+ Branch 40
+ 40: Label
+ BranchConditional 20 37 39
39: Label
- 48: 17(bool) Load 47(cond)
- SelectionMerge 50 Flatten
- BranchConditional 48 49 50
- 49: Label
- Branch 50
- 50: Label
- 51: 17(bool) Load 47(cond)
- SelectionMerge 53 DontFlatten
- BranchConditional 51 52 53
- 52: Label
- Store 47(cond) 54
- Branch 53
- 53: Label
- SelectionMerge 57 DontFlatten
- Switch 55 57
- case 3: 56
- 56: Label
- Branch 57
- 57: Label
- Store 60(i) 9
- Branch 61
- 61: Label
- LoopMerge 63 64 None
- Branch 65
- 65: Label
- 66: 6(int) Load 60(i)
- 67: 17(bool) SLessThan 66 16
- BranchConditional 67 62 63
- 62: Label
- Branch 64
- 64: Label
- 68: 6(int) Load 60(i)
- 69: 6(int) IAdd 68 20
- Store 60(i) 69
- Branch 61
- 63: Label
+ Store 41(i) 24
+ Branch 42
+ 42: Label
+ LoopMerge 44 45 DependencyLength 4
+ Branch 46
+ 46: Label
+ 47: 21(int) Load 41(i)
+ 48: 19(bool) SLessThan 47 31
+ BranchConditional 48 43 44
+ 43: Label
+ Branch 45
+ 45: Label
+ 49: 21(int) Load 41(i)
+ 50: 21(int) IAdd 49 34
+ Store 41(i) 50
+ Branch 42
+ 44: Label
+ 53: 19(bool) Load 52(cond)
+ SelectionMerge 55 Flatten
+ BranchConditional 53 54 55
+ 54: Label
+ Branch 55
+ 55: Label
+ 56: 19(bool) Load 52(cond)
+ SelectionMerge 58 DontFlatten
+ BranchConditional 56 57 58
+ 57: Label
+ Store 52(cond) 59
+ Branch 58
+ 58: Label
+ SelectionMerge 62 DontFlatten
+ Switch 60 62
+ case 3: 61
+ 61: Label
+ Branch 62
+ 62: Label
+ Store 65(i) 24
+ Branch 66
+ 66: Label
+ LoopMerge 68 69 None
Branch 70
70: Label
- LoopMerge 72 73 None
- Branch 74
- 74: Label
- BranchConditional 31 71 72
- 71: Label
- Branch 73
- 73: Label
- Branch 70
- 72: Label
+ 71: 21(int) Load 65(i)
+ 72: 19(bool) SLessThan 71 31
+ BranchConditional 72 67 68
+ 67: Label
+ Branch 69
+ 69: Label
+ 73: 21(int) Load 65(i)
+ 74: 21(int) IAdd 73 34
+ Store 65(i) 74
+ Branch 66
+ 68: Label
Branch 75
75: Label
LoopMerge 77 78 None
- Branch 76
- 76: Label
- Branch 78
- 78: Label
- BranchConditional 31 75 77
+ Branch 79
+ 79: Label
+ BranchConditional 20 76 77
+ 76: Label
+ Branch 78
+ 78: Label
+ Branch 75
77: Label
- Store 79(i) 9
Branch 80
80: Label
LoopMerge 82 83 None
- Branch 84
- 84: Label
- 85: 6(int) Load 79(i)
- 86: 17(bool) SLessThan 85 16
- BranchConditional 86 81 82
- 81: Label
- Branch 83
- 83: Label
- 87: 6(int) Load 79(i)
- 88: 6(int) IAdd 87 20
- Store 79(i) 88
- Branch 80
+ Branch 81
+ 81: Label
+ Branch 83
+ 83: Label
+ BranchConditional 20 80 82
82: Label
- 89: 17(bool) Load 47(cond)
- SelectionMerge 91 None
- BranchConditional 89 90 91
- 90: Label
- Branch 91
- 91: Label
- 92: 17(bool) Load 47(cond)
- SelectionMerge 94 None
- BranchConditional 92 93 94
- 93: Label
- Store 47(cond) 54
- Branch 94
- 94: Label
+ Store 84(i) 24
+ Branch 85
+ 85: Label
+ LoopMerge 87 88 None
+ Branch 89
+ 89: Label
+ 90: 21(int) Load 84(i)
+ 91: 19(bool) SLessThan 90 31
+ BranchConditional 91 86 87
+ 86: Label
+ Branch 88
+ 88: Label
+ 92: 21(int) Load 84(i)
+ 93: 21(int) IAdd 92 34
+ Store 84(i) 93
+ Branch 85
+ 87: Label
+ 94: 19(bool) Load 52(cond)
SelectionMerge 96 None
- Switch 55 96
- case 3: 95
+ BranchConditional 94 95 96
95: Label
Branch 96
96: Label
- Branch 99
- 99: Label
- LoopMerge 101 102 Unroll DontUnroll DependencyLength 2
- Branch 103
- 103: Label
- 104: 17(bool) Load 47(cond)
- BranchConditional 104 100 101
- 100: Label
- Branch 102
- 102: Label
+ 97: 19(bool) Load 52(cond)
+ SelectionMerge 99 None
+ BranchConditional 97 98 99
+ 98: Label
+ Store 52(cond) 59
Branch 99
+ 99: Label
+ SelectionMerge 101 None
+ Switch 60 101
+ case 3: 100
+ 100: Label
+ Branch 101
101: Label
- SelectionMerge 106 DontFlatten
- Switch 55 106
- case 3: 105
+ Branch 104
+ 104: Label
+ LoopMerge 106 107 Unroll DontUnroll DependencyLength 2
+ Branch 108
+ 108: Label
+ 109: 19(bool) Load 52(cond)
+ BranchConditional 109 105 106
105: Label
- Branch 106
+ Branch 107
+ 107: Label
+ Branch 104
106: Label
- 109: 17(bool) Load 47(cond)
- SelectionMerge 111 Flatten
- BranchConditional 109 110 111
+ SelectionMerge 111 DontFlatten
+ Switch 60 111
+ case 3: 110
110: Label
Branch 111
111: Label
- Branch 112
- 112: Label
- LoopMerge 114 115 DependencyInfinite
- Branch 116
- 116: Label
- 117: 17(bool) Load 47(cond)
- BranchConditional 117 113 114
- 113: Label
- Branch 115
+ 114: 19(bool) Load 52(cond)
+ SelectionMerge 116 Flatten
+ BranchConditional 114 115 116
115: Label
- Branch 112
- 114: Label
+ Branch 116
+ 116: Label
+ Branch 117
+ 117: Label
+ LoopMerge 119 120 DependencyInfinite
+ Branch 121
+ 121: Label
+ 122: 19(bool) Load 52(cond)
+ BranchConditional 122 118 119
+ 118: Label
+ Branch 120
+ 120: Label
+ Branch 117
+ 119: Label
+ Return
+ FunctionEnd
+ 6(f0(): 2 Function None 3
+ 7: Label
+ Branch 10
+ 10: Label
+ LoopMerge 12 13 DontUnroll
+ Branch 11
+ 11: Label
+ Branch 13
+ 13: Label
+ Branch 10
+ 12: Label
+ Unreachable
+ FunctionEnd
+ 8(f1(): 2 Function None 3
+ 9: Label
+ Branch 14
+ 14: Label
+ LoopMerge 16 17 DontUnroll
+ Branch 18
+ 18: Label
+ BranchConditional 20 15 16
+ 15: Label
+ Branch 17
+ 17: Label
+ Branch 14
+ 16: Label
Return
FunctionEnd
diff --git a/Test/baseResults/spv.dead-after-continue.vert.out b/Test/baseResults/spv.dead-after-continue.vert.out
new file mode 100644
index 0000000..9d85fdc
--- /dev/null
+++ b/Test/baseResults/spv.dead-after-continue.vert.out
@@ -0,0 +1,54 @@
+spv.dead-after-continue.vert
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 29
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 20 28
+ Source GLSL 450
+ Name 4 "main"
+ Name 8 "i"
+ Name 20 "o"
+ Name 28 "c"
+ Decorate 20(o) Location 0
+ Decorate 28(c) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Function 6(int)
+ 9: 6(int) Constant 0
+ 16: 6(int) Constant 5
+ 17: TypeBool
+ 19: TypePointer Output 6(int)
+ 20(o): 19(ptr) Variable Output
+ 21: 6(int) Constant 1
+ 23: 6(int) Constant 2
+ 26: 6(int) Constant 3
+ 27: TypePointer Input 6(int)
+ 28(c): 27(ptr) Variable Input
+ 4(main): 2 Function None 3
+ 5: Label
+ 8(i): 7(ptr) Variable Function
+ Store 8(i) 9
+ Branch 10
+ 10: Label
+ LoopMerge 12 13 None
+ Branch 14
+ 14: Label
+ 15: 6(int) Load 8(i)
+ 18: 17(bool) SLessThan 15 16
+ BranchConditional 18 11 12
+ 11: Label
+ Store 20(o) 21
+ Branch 13
+ 13: Label
+ 24: 6(int) Load 8(i)
+ 25: 6(int) IAdd 24 21
+ Store 8(i) 25
+ Branch 10
+ 12: Label
+ Store 20(o) 26
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.dead-after-discard.frag.out b/Test/baseResults/spv.dead-after-discard.frag.out
new file mode 100644
index 0000000..2c2a595
--- /dev/null
+++ b/Test/baseResults/spv.dead-after-discard.frag.out
@@ -0,0 +1,31 @@
+spv.dead-after-discard.frag
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 15
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 8 14
+ ExecutionMode 4 OriginUpperLeft
+ Source GLSL 450
+ Name 4 "main"
+ Name 8 "o"
+ Name 14 "c"
+ Decorate 8(o) Location 0
+ Decorate 14(c) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Output 6(int)
+ 8(o): 7(ptr) Variable Output
+ 9: 6(int) Constant 1
+ 11: 6(int) Constant 3
+ 12: TypeFloat 32
+ 13: TypePointer Input 12(float)
+ 14(c): 13(ptr) Variable Input
+ 4(main): 2 Function None 3
+ 5: Label
+ Store 8(o) 9
+ Kill
+ FunctionEnd
diff --git a/Test/baseResults/spv.dead-after-loop-break.vert.out b/Test/baseResults/spv.dead-after-loop-break.vert.out
new file mode 100644
index 0000000..8cf187d
--- /dev/null
+++ b/Test/baseResults/spv.dead-after-loop-break.vert.out
@@ -0,0 +1,67 @@
+spv.dead-after-loop-break.vert
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 36
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 8 25
+ Source GLSL 450
+ Name 4 "main"
+ Name 8 "o"
+ Name 11 "i"
+ Name 25 "c"
+ Decorate 8(o) Location 0
+ Decorate 25(c) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Output 6(int)
+ 8(o): 7(ptr) Variable Output
+ 9: 6(int) Constant 1
+ 10: TypePointer Function 6(int)
+ 12: 6(int) Constant 0
+ 19: 6(int) Constant 5
+ 20: TypeBool
+ 22: 6(int) Constant 2
+ 24: TypePointer Input 6(int)
+ 25(c): 24(ptr) Variable Input
+ 30: 6(int) Constant 3
+ 32: 6(int) Constant 4
+ 35: 6(int) Constant 6
+ 4(main): 2 Function None 3
+ 5: Label
+ 11(i): 10(ptr) Variable Function
+ Store 8(o) 9
+ Store 11(i) 12
+ Branch 13
+ 13: Label
+ LoopMerge 15 16 None
+ Branch 17
+ 17: Label
+ 18: 6(int) Load 11(i)
+ 21: 20(bool) SLessThan 18 19
+ BranchConditional 21 14 15
+ 14: Label
+ Store 8(o) 22
+ 23: 6(int) Load 11(i)
+ 26: 6(int) Load 25(c)
+ 27: 20(bool) IEqual 23 26
+ SelectionMerge 29 None
+ BranchConditional 27 28 29
+ 28: Label
+ Store 8(o) 30
+ Branch 15
+ 29: Label
+ Store 8(o) 19
+ Branch 16
+ 16: Label
+ 33: 6(int) Load 11(i)
+ 34: 6(int) IAdd 33 9
+ Store 11(i) 34
+ Branch 13
+ 15: Label
+ Store 8(o) 35
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.dead-after-return.vert.out b/Test/baseResults/spv.dead-after-return.vert.out
new file mode 100644
index 0000000..f8af0c4
--- /dev/null
+++ b/Test/baseResults/spv.dead-after-return.vert.out
@@ -0,0 +1,29 @@
+spv.dead-after-return.vert
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 14
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 8 13
+ Source GLSL 450
+ Name 4 "main"
+ Name 8 "o"
+ Name 13 "c"
+ Decorate 8(o) Location 0
+ Decorate 13(c) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Output 6(int)
+ 8(o): 7(ptr) Variable Output
+ 9: 6(int) Constant 1
+ 11: 6(int) Constant 3
+ 12: TypePointer Input 6(int)
+ 13(c): 12(ptr) Variable Input
+ 4(main): 2 Function None 3
+ 5: Label
+ Store 8(o) 9
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.dead-after-switch-break.vert.out b/Test/baseResults/spv.dead-after-switch-break.vert.out
new file mode 100644
index 0000000..7b27fc7
--- /dev/null
+++ b/Test/baseResults/spv.dead-after-switch-break.vert.out
@@ -0,0 +1,40 @@
+spv.dead-after-switch-break.vert
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 21
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 8 14
+ Source GLSL 450
+ Name 4 "main"
+ Name 8 "c"
+ Name 14 "o"
+ Decorate 8(c) Location 0
+ Decorate 14(o) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Input 6(int)
+ 8(c): 7(ptr) Variable Input
+ 13: TypePointer Output 6(int)
+ 14(o): 13(ptr) Variable Output
+ 15: 6(int) Constant 1
+ 17: 6(int) Constant 2
+ 20: 6(int) Constant 3
+ 4(main): 2 Function None 3
+ 5: Label
+ 9: 6(int) Load 8(c)
+ SelectionMerge 12 None
+ Switch 9 11
+ case 0: 10
+ 11: Label
+ Branch 12
+ 10: Label
+ Store 14(o) 15
+ Branch 12
+ 12: Label
+ Store 14(o) 20
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.dead-complex-continue-after-return.vert.out b/Test/baseResults/spv.dead-complex-continue-after-return.vert.out
new file mode 100644
index 0000000..23ac200
--- /dev/null
+++ b/Test/baseResults/spv.dead-complex-continue-after-return.vert.out
@@ -0,0 +1,55 @@
+spv.dead-complex-continue-after-return.vert
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 31
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 11 30
+ Source GLSL 450
+ Name 4 "main"
+ Name 8 "i"
+ Name 11 "o"
+ Name 30 "c"
+ Decorate 11(o) Location 0
+ Decorate 30(c) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Function 6(int)
+ 9: 6(int) Constant 0
+ 10: TypePointer Output 6(int)
+ 11(o): 10(ptr) Variable Output
+ 12: 6(int) Constant 1
+ 19: 6(int) Constant 5
+ 20: TypeBool
+ 22: 6(int) Constant 2
+ 24: 6(int) Constant 3
+ 27: 6(int) Constant 99
+ 28: 6(int) Constant 4
+ 29: TypePointer Input 6(int)
+ 30(c): 29(ptr) Variable Input
+ 4(main): 2 Function None 3
+ 5: Label
+ 8(i): 7(ptr) Variable Function
+ Store 8(i) 9
+ Store 11(o) 12
+ Store 8(i) 9
+ Branch 13
+ 13: Label
+ LoopMerge 15 16 None
+ Branch 17
+ 17: Label
+ 18: 6(int) Load 8(i)
+ 21: 20(bool) SLessThan 18 19
+ BranchConditional 21 14 15
+ 14: Label
+ Store 11(o) 22
+ Return
+ 16: Label
+ Branch 13
+ 15: Label
+ Store 11(o) 28
+ Return
+ FunctionEnd
diff --git a/Test/baseResults/spv.dead-complex-merge-after-return.vert.out b/Test/baseResults/spv.dead-complex-merge-after-return.vert.out
new file mode 100644
index 0000000..1c0867e
--- /dev/null
+++ b/Test/baseResults/spv.dead-complex-merge-after-return.vert.out
@@ -0,0 +1,51 @@
+spv.dead-complex-merge-after-return.vert
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 36
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 11 27
+ Source GLSL 450
+ Name 4 "main"
+ Name 8 "i"
+ Name 11 "o"
+ Name 27 "c"
+ Decorate 11(o) Location 0
+ Decorate 27(c) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Function 6(int)
+ 9: 6(int) Constant 0
+ 10: TypePointer Output 6(int)
+ 11(o): 10(ptr) Variable Output
+ 12: 6(int) Constant 1
+ 17: 6(int) Constant 2
+ 19: 6(int) Constant 3
+ 22: 6(int) Constant 5
+ 23: TypeBool
+ 25: 6(int) Constant 4
+ 26: TypePointer Input 6(int)
+ 27(c): 26(ptr) Variable Input
+ 32: 6(int) Constant 100
+ 34: 6(int) Constant 200
+ 35: 6(int) Constant 300
+ 4(main): 2 Function None 3
+ 5: Label
+ 8(i): 7(ptr) Variable Function
+ Store 8(i) 9
+ Store 11(o) 12
+ Branch 13
+ 13: Label
+ LoopMerge 15 16 None
+ Branch 14
+ 14: Label
+ Store 11(o) 17
+ Return
+ 16: Label
+ Branch 13
+ 15: Label
+ Unreachable
+ FunctionEnd
diff --git a/Test/baseResults/spv.earlyReturnDiscard.frag.out b/Test/baseResults/spv.earlyReturnDiscard.frag.out
index c44b722..bb11b28 100644
--- a/Test/baseResults/spv.earlyReturnDiscard.frag.out
+++ b/Test/baseResults/spv.earlyReturnDiscard.frag.out
@@ -160,7 +160,7 @@
102: Label
Return
100: Label
- Branch 67
+ Unreachable
67: Label
106: 7(fvec4) Load 9(color)
107: 7(fvec4) Load 13(color2)
diff --git a/Test/baseResults/spv.for-notest.vert.out b/Test/baseResults/spv.for-notest.vert.out
index 36c4a96..c9d5b4c 100644
--- a/Test/baseResults/spv.for-notest.vert.out
+++ b/Test/baseResults/spv.for-notest.vert.out
@@ -38,5 +38,5 @@
Store 8(i) 19
Branch 10
12: Label
- Return
+ Unreachable
FunctionEnd
diff --git a/Test/baseResults/spv.forwardFun.frag.out b/Test/baseResults/spv.forwardFun.frag.out
index 32875b2..3e96403 100644
--- a/Test/baseResults/spv.forwardFun.frag.out
+++ b/Test/baseResults/spv.forwardFun.frag.out
@@ -99,8 +99,7 @@
45: Label
ReturnValue 46
42: Label
- 48: 8(float) Undef
- ReturnValue 48
+ Unreachable
FunctionEnd
16(foo(vf4;): 8(float) Function None 14
15(bar): 13(ptr) FunctionParameter
diff --git a/Test/baseResults/spv.functionCall.frag.out b/Test/baseResults/spv.functionCall.frag.out
index 269b74e..a8b7ad1 100644
--- a/Test/baseResults/spv.functionCall.frag.out
+++ b/Test/baseResults/spv.functionCall.frag.out
@@ -105,8 +105,7 @@
44: Label
ReturnValue 45
41: Label
- 47: 6(float) Undef
- ReturnValue 47
+ Unreachable
FunctionEnd
18(missingReturn(): 6(float) Function None 15
19: Label
diff --git a/Test/baseResults/spv.merge-unreachable.frag.out b/Test/baseResults/spv.merge-unreachable.frag.out
index 7ec0f33..1c2234d 100644
--- a/Test/baseResults/spv.merge-unreachable.frag.out
+++ b/Test/baseResults/spv.merge-unreachable.frag.out
@@ -37,5 +37,5 @@
23: Label
Return
21: Label
- Return
+ Unreachable
FunctionEnd
diff --git a/Test/hlsl.doLoop.frag b/Test/hlsl.doLoop.frag
index 0318dc8..8f4bfdc 100644
--- a/Test/hlsl.doLoop.frag
+++ b/Test/hlsl.doLoop.frag
@@ -1,9 +1,29 @@
+void f0() {
+ [unroll] do {} while (false);
+}
+
+void f1() {
+ [unroll] do {;} while (false);
+}
+
+float f2(float input) {
+ do { return (float4)input; } while (input > 2.0);
+}
+
+void f3(float input) {
+ do ++input; while (input < 10.0);
+}
+
+void f4(float input) {
+ do while (++input < 10.0); while (++input < 10.0); // nest while inside do-while
+}
+
float4 PixelShaderFunction(float input) : COLOR0
{
- [unroll] do {} while (false);
- [unroll] do {;} while (false);
- do { return (float4)input; } while (input > 2.0);
- do ++input; while (input < 10.0);
- do while (++input < 10.0); while (++input < 10.0); // nest while inside do-while
+ f0();
+ f1();
+ f2(input);
+ f3(input);
+ f4(input);
return (float4)input;
}
diff --git a/Test/hlsl.forLoop.frag b/Test/hlsl.forLoop.frag
index 9cf60ee..c0783db 100644
--- a/Test/hlsl.forLoop.frag
+++ b/Test/hlsl.forLoop.frag
@@ -1,17 +1,59 @@
+void f0() {
+ for (;;) ;
+}
+
+void f1(float4 input) {
+ for (++input; ; ) ;
+}
+
+void f2(float4 input) {
+ [unroll] for (; any(input != input); ) {}
+}
+
+float f3(float4 input) {
+ for (; any(input != input); ) { return -input; }
+}
+
+float f4(float4 input) {
+ for (--input; any(input != input); input += 2) { return -input; }
+}
+
+void f5(float4 input) {
+ for (;;) if (input.x > 2.0) break;
+}
+
+void f6(float4 input) {
+ for (;;) if (input.x > 2.0) continue;
+}
+
+void f99() {
+ for (int first = 0, second = 1; ;) first + second;
+}
+
+void f100(float ii) {
+ for (--ii, --ii, --ii;;) ii;
+}
+
float4 PixelShaderFunction(float4 input) : COLOR0
{
- for (;;) ;
- for (++input; ; ) ;
- [unroll] for (; any(input != input); ) {}
- for (; any(input != input); ) { return -input; }
- for (--input; any(input != input); input += 2) { return -input; }
- for (;;) if (input.x > 2.0) break;
- for (;;) if (input.x > 2.0) continue;
+ f0();
+ f1(input);
+ f2(input);
+ f3(input);
+ f4(input);
+ f5(input);
+ f6(input);
+
float ii;
for (int ii = -1; ii < 3; ++ii) if (ii == 2) continue;
--ii;
- for (int first = 0, second = 1; ;) first + second;
+
+ f99();
+
for ( int i = 0, count = int(ii); i < count; i++ );
for (float first = 0, second[2], third; first < second[0]; ++second[1]) first + second[1] + third;
- for (--ii, --ii, --ii;;) ii;
+
+ f100(ii);
+
+ return input;
}
diff --git a/Test/hlsl.if.frag b/Test/hlsl.if.frag
index b62eda1..a2e47f6 100644
--- a/Test/hlsl.if.frag
+++ b/Test/hlsl.if.frag
@@ -1,12 +1,24 @@
+float4 f0(float4 input) {
+ if (all(input == input))
+ return input;
+ else
+ return -input;
+}
+
+float4 f1(float4 input) {
+ if (all(input == input)) {
+ return input;
+ } else {
+ return -input;
+ }
+}
+
float4 PixelShaderFunction(float4 input) : COLOR0
{
if (all(input == input))
return input;
- if (all(input == input))
- return input;
- else
- return -input;
+ f0(input);
if (all(input == input))
;
@@ -20,11 +32,7 @@
return input;
}
- if (all(input == input)) {
- return input;
- } else {
- return -input;
- }
+ f1(input);
int ii;
if (float ii = input.z)
diff --git a/Test/spv.controlFlowAttributes.frag b/Test/spv.controlFlowAttributes.frag
index 6d90c0d..cedd602 100644
--- a/Test/spv.controlFlowAttributes.frag
+++ b/Test/spv.controlFlowAttributes.frag
@@ -4,11 +4,18 @@
bool cond;
+void f0() {
+ [[loop]] for (;;) { }
+}
+
+void f1() {
+ [[dont_unroll]] while(true) { }
+}
+
void main()
{
[[unroll]] for (int i = 0; i < 8; ++i) { }
- [[loop]] for (;;) { }
- [[dont_unroll]] while(true) { }
+ f0();
[[dependency_infinite]] do { } while(true);
[[dependency_length(1+3)]] for (int i = 0; i < 8; ++i) { }
[[flatten]] if (cond) { } else { }
diff --git a/Test/spv.dead-after-continue.vert b/Test/spv.dead-after-continue.vert
new file mode 100644
index 0000000..86e8eea
--- /dev/null
+++ b/Test/spv.dead-after-continue.vert
@@ -0,0 +1,14 @@
+#version 450
+
+layout(location =0 ) in int c;
+layout(location =0 ) out int o;
+
+void main() {
+ int i;
+ for (i=0; i < 5; i++) {
+ o = 1;
+ continue;
+ o = 2;
+ }
+ o = 3;
+}
diff --git a/Test/spv.dead-after-discard.frag b/Test/spv.dead-after-discard.frag
new file mode 100644
index 0000000..769592b
--- /dev/null
+++ b/Test/spv.dead-after-discard.frag
@@ -0,0 +1,10 @@
+#version 450
+
+layout(location =0 ) in float c;
+layout(location =0 ) out int o;
+
+void main() {
+ o = 1;
+ discard;
+ o = 3;
+}
diff --git a/Test/spv.dead-after-loop-break.vert b/Test/spv.dead-after-loop-break.vert
new file mode 100644
index 0000000..5498497
--- /dev/null
+++ b/Test/spv.dead-after-loop-break.vert
@@ -0,0 +1,19 @@
+#version 450
+
+layout(location =0 ) in int c;
+layout(location =0 ) out int o;
+
+void main() {
+ int i;
+ o = 1;
+ for (i=0; i < 5; i++) {
+ o = 2;
+ if (i==c) {
+ o = 3;
+ break;
+ o = 4;
+ }
+ o = 5;
+ }
+ o = 6;
+}
diff --git a/Test/spv.dead-after-return.vert b/Test/spv.dead-after-return.vert
new file mode 100644
index 0000000..7172696
--- /dev/null
+++ b/Test/spv.dead-after-return.vert
@@ -0,0 +1,10 @@
+#version 450
+
+layout(location =0 ) in int c;
+layout(location =0 ) out int o;
+
+void main() {
+ o = 1;
+ return;
+ o = 3;
+}
diff --git a/Test/spv.dead-after-switch-break.vert b/Test/spv.dead-after-switch-break.vert
new file mode 100644
index 0000000..b1483e8
--- /dev/null
+++ b/Test/spv.dead-after-switch-break.vert
@@ -0,0 +1,15 @@
+#version 450
+
+layout(location =0 ) in int c;
+layout(location =0 ) out int o;
+
+void main() {
+ int i;
+ switch(c) {
+ case 0: o=1;
+ break;
+ o=2;
+ default: break;
+ }
+ o = 3;
+}
diff --git a/Test/spv.dead-complex-continue-after-return.vert b/Test/spv.dead-complex-continue-after-return.vert
new file mode 100644
index 0000000..85932a3
--- /dev/null
+++ b/Test/spv.dead-complex-continue-after-return.vert
@@ -0,0 +1,19 @@
+#version 450
+
+layout(location =0 ) in int c;
+layout(location =0 ) out int o;
+
+void main() {
+ int i = 0;
+ o = 1;
+ // This has non-trivial continue target.
+ for (i=0; i < 5; ++i, o=99) {
+ o = 2;
+ return;
+ o = 3;
+ }
+ // This is considered reachable since Glslang codegen will
+ // create a conditional branch in the header, and one arm
+ // of that branch reaches this merge block.
+ o = 4;
+}
diff --git a/Test/spv.dead-complex-merge-after-return.vert b/Test/spv.dead-complex-merge-after-return.vert
new file mode 100644
index 0000000..2fff1a2
--- /dev/null
+++ b/Test/spv.dead-complex-merge-after-return.vert
@@ -0,0 +1,23 @@
+#version 450
+
+layout(location =0 ) in int c;
+layout(location =0 ) out int o;
+
+void main() {
+ int i = 0;
+ o = 1;
+ do {
+ o = 2;
+ return;
+ o = 3;
+ } while(i++ < 5);
+
+ // All this is a dead merge block.
+ o = 4;
+ if (c==4) {
+ o = 100;
+ } else {
+ o = 200;
+ }
+ o = 300;
+}
diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp
index 9620341..ce5960c 100644
--- a/gtests/Spv.FromFile.cpp
+++ b/gtests/Spv.FromFile.cpp
@@ -63,6 +63,7 @@
}
using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
+using CompileVulkanToSpirvDeadCodeElimTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkanToDebugSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkan1_1ToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileToSpirv14Test = GlslangTest<::testing::TestWithParam<std::string>>;
@@ -85,6 +86,13 @@
Target::Spv);
}
+TEST_P(CompileVulkanToSpirvDeadCodeElimTest, FromFile)
+{
+ loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
+ Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
+ Target::Spv);
+}
+
// Compiling GLSL to SPIR-V with debug info under Vulkan semantics. Expected
// to successfully generate SPIR-V.
TEST_P(CompileVulkanToDebugSpirvTest, FromFile)
@@ -417,6 +425,23 @@
FileNameAsCustomTestSuffix
);
+// Cases with deliberately unreachable code.
+// By default the compiler will aggressively eliminate
+// unreachable merges and continues.
+INSTANTIATE_TEST_CASE_P(
+ GlslWithDeadCode, CompileVulkanToSpirvDeadCodeElimTest,
+ ::testing::ValuesIn(std::vector<std::string>({
+ "spv.dead-after-continue.vert",
+ "spv.dead-after-discard.frag",
+ "spv.dead-after-return.vert",
+ "spv.dead-after-loop-break.vert",
+ "spv.dead-after-switch-break.vert",
+ "spv.dead-complex-continue-after-return.vert",
+ "spv.dead-complex-merge-after-return.vert",
+ })),
+ FileNameAsCustomTestSuffix
+);
+
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkanToDebugSpirvTest,
diff --git a/gtests/TestFixture.h b/gtests/TestFixture.h
index 61a8f23..8d2ebd9 100755
--- a/gtests/TestFixture.h
+++ b/gtests/TestFixture.h
@@ -113,7 +113,7 @@
forceVersionProfile(false),
isForwardCompatible(false) {
// Perform validation by default.
- validatorOptions.validate = true;
+ spirvOptions.validate = true;
}
// Tries to load the contents from the file at the given |path|. On success,
@@ -693,14 +693,14 @@
expectedOutputFname, result.spirvWarningsErrors);
}
- glslang::SpvOptions& options() { return validatorOptions; }
+ glslang::SpvOptions& options() { return spirvOptions; }
private:
const int defaultVersion;
const EProfile defaultProfile;
const bool forceVersionProfile;
const bool isForwardCompatible;
- glslang::SpvOptions validatorOptions;
+ glslang::SpvOptions spirvOptions;
};
} // namespace glslangtest