Fix #231 and #232.

Split apart the early-exit loop tests and ensure that %val defs dominate
uses and OpPhi instructions always mention parent blocks.
diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp
index da8bb57..02cf857 100644
--- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp
+++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp
@@ -7287,8 +7287,8 @@
 		"OpFunctionEnd\n";
 	createTestsForAllStages("continue", defaultColors, defaultColors, fragments, testGroup.get());
 
-	// A loop with early exit.  May be specialized with either break or return.
-	StringTemplate earlyExitLoop(
+	// A loop with break.
+	fragments["testfun"] =
 		"%test_code = OpFunction %v4f32 None %v4f32_function\n"
 		"%param1 = OpFunctionParameter %v4f32\n"
 
@@ -7304,7 +7304,7 @@
 		";adds 4 and 3 to %val0 (exits early)\n"
 		"%loop = OpLabel\n"
 		"%count = OpPhi %i32 %c_i32_4 %entry %count__ %continue\n"
-		"%val1 = OpPhi %f32 %val0 %entry %val %continue\n"
+		"%val1 = OpPhi %f32 %val0 %entry %val2 %continue\n"
 		"OpLoopMerge %exit %continue None\n"
 		"OpBranch %if\n"
 
@@ -7312,8 +7312,7 @@
 		";end loop if %count==%two\n"
 		"%above2 = OpSGreaterThan %bool %count %two\n"
 		"OpSelectionMerge %continue DontFlatten\n"
-		// This can either branch to %exit or to another block with OpReturnValue %param1.
-		"OpBranchConditional %above2 %body ${branch_destination}\n"
+		"OpBranchConditional %above2 %body %exit\n"
 
 		"%body = OpLabel\n"
 		"%fcount = OpConvertSToF %f32 %count\n"
@@ -7321,29 +7320,63 @@
 		"OpBranch %continue\n"
 
 		"%continue = OpLabel\n"
-		"%val = OpPhi %f32 %val2 %body %val1 %if\n"
 		"%count__ = OpISub %i32 %count %c_i32_1\n"
 		"%again = OpSGreaterThan %bool %count__ %c_i32_0\n"
 		"OpBranchConditional %again %loop %exit\n"
 
 		"%exit = OpLabel\n"
-		"%same = OpFSub %f32 %val %c_f32_7\n"
+		"%val_post = OpPhi %f32 %val2 %continue %val1 %if\n"
+		"%same = OpFSub %f32 %val_post %c_f32_7\n"
 		"%result = OpVectorInsertDynamic %v4f32 %param1 %same %c_i32_0\n"
 		"OpReturnValue %result\n"
-		"OpFunctionEnd\n");
-
-	map<string, string> branch_destination;
-
-	// A loop with break.
-	branch_destination["branch_destination"] = "%exit";
-	fragments["testfun"] = earlyExitLoop.specialize(branch_destination);
+		"OpFunctionEnd\n";
 	createTestsForAllStages("break", defaultColors, defaultColors, fragments, testGroup.get());
 
 	// A loop with return.
-	branch_destination["branch_destination"] = "%early_exit\n"
+	fragments["testfun"] =
+		"%test_code = OpFunction %v4f32 None %v4f32_function\n"
+		"%param1 = OpFunctionParameter %v4f32\n"
+
+		"%entry = OpLabel\n"
+		";param1 components are between 0 and 1, so dot product is 4 or less\n"
+		"%dot = OpDot %f32 %param1 %param1\n"
+		"%div = OpFDiv %f32 %dot %c_f32_5\n"
+		"%zero = OpConvertFToU %u32 %div\n"
+		"%two = OpIAdd %i32 %zero %c_i32_2\n"
+		"%val0 = OpVectorExtractDynamic %f32 %param1 %c_i32_0\n"
+		"OpBranch %loop\n"
+
+		";returns early without modifying %param1\n"
+		"%loop = OpLabel\n"
+		"%count = OpPhi %i32 %c_i32_4 %entry %count__ %continue\n"
+		"%val1 = OpPhi %f32 %val0 %entry %val2 %continue\n"
+		"OpLoopMerge %exit %continue None\n"
+		"OpBranch %if\n"
+
+		"%if = OpLabel\n"
+		";return if %count==%two\n"
+		"%above2 = OpSGreaterThan %bool %count %two\n"
+		"OpSelectionMerge %continue DontFlatten\n"
+		"OpBranchConditional %above2 %body %early_exit\n"
+
 		"%early_exit = OpLabel\n"
-		"OpReturnValue %param1\n";
-	fragments["testfun"] = earlyExitLoop.specialize(branch_destination);
+		"OpReturnValue %param1\n"
+
+		"%body = OpLabel\n"
+		"%fcount = OpConvertSToF %f32 %count\n"
+		"%val2 = OpFAdd %f32 %val1 %fcount\n"
+		"OpBranch %continue\n"
+
+		"%continue = OpLabel\n"
+		"%count__ = OpISub %i32 %count %c_i32_1\n"
+		"%again = OpSGreaterThan %bool %count__ %c_i32_0\n"
+		"OpBranchConditional %again %loop %exit\n"
+
+		"%exit = OpLabel\n"
+		";should never get here, so return an incorrect result\n"
+		"%result = OpVectorInsertDynamic %v4f32 %param1 %val2 %c_i32_0\n"
+		"OpReturnValue %result\n"
+		"OpFunctionEnd\n";
 	createTestsForAllStages("return", defaultColors, defaultColors, fragments, testGroup.get());
 
 	return testGroup.release();