Fix loops with dynamic iteration count.

The 'enable' execution mask for if/else, which is also used by loops,
was not being applied to predicate the instructions within a loop.

Bug b/28710510

Change-Id: Ibd8e962ef60de76ec1c018ca064a791abf214c94
Reviewed-on: https://swiftshader-review.googlesource.com/15948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Shader/Shader.cpp b/src/Shader/Shader.cpp
index 549b8bd..025b5d5 100644
--- a/src/Shader/Shader.cpp
+++ b/src/Shader/Shader.cpp
@@ -1684,12 +1684,12 @@
 
 		for(unsigned int i = 0; i < instruction.size(); i++)
 		{
-			// If statements
-			if(instruction[i]->isBranch())
+			// If statements and loops
+			if(instruction[i]->isBranch() || instruction[i]->isLoop())
 			{
 				branchDepth++;
 			}
-			else if(instruction[i]->opcode == OPCODE_ENDIF)
+			else if(instruction[i]->opcode == OPCODE_ENDIF || instruction[i]->isEndLoop())
 			{
 				branchDepth--;
 			}