spirv-fuzz: Fix operand types (#3962)

Fixes #3945.
Fixes #3946.
diff --git a/source/fuzz/transformation_flatten_conditional_branch.cpp b/source/fuzz/transformation_flatten_conditional_branch.cpp
index 83b98d0..7c6fe7a 100644
--- a/source/fuzz/transformation_flatten_conditional_branch.cpp
+++ b/source/fuzz/transformation_flatten_conditional_branch.cpp
@@ -867,7 +867,7 @@
               // OpSelect's condition, and note the fact that we will need to
               // add an instruction to bring this bvec2 into existence.
               if (message_.fresh_id_for_bvec2_selector() != 0) {
-                selector_operand = {SPV_OPERAND_TYPE_TYPE_ID,
+                selector_operand = {SPV_OPERAND_TYPE_ID,
                                     {message_.fresh_id_for_bvec2_selector()}};
                 require_2d_boolean_vector = true;
               }
@@ -875,7 +875,7 @@
             case 3:
               // Similar to the 2D case.
               if (message_.fresh_id_for_bvec3_selector() != 0) {
-                selector_operand = {SPV_OPERAND_TYPE_TYPE_ID,
+                selector_operand = {SPV_OPERAND_TYPE_ID,
                                     {message_.fresh_id_for_bvec3_selector()}};
                 require_3d_boolean_vector = true;
               }
@@ -884,7 +884,7 @@
               assert(dimension == 4 && "Invalid vector dimension.");
               // Similar to the 2D case.
               if (message_.fresh_id_for_bvec4_selector() != 0) {
-                selector_operand = {SPV_OPERAND_TYPE_TYPE_ID,
+                selector_operand = {SPV_OPERAND_TYPE_ID,
                                     {message_.fresh_id_for_bvec4_selector()}};
                 require_4d_boolean_vector = true;
               }
diff --git a/source/fuzz/transformation_merge_function_returns.cpp b/source/fuzz/transformation_merge_function_returns.cpp
index c693444..90578a2 100644
--- a/source/fuzz/transformation_merge_function_returns.cpp
+++ b/source/fuzz/transformation_merge_function_returns.cpp
@@ -517,7 +517,7 @@
       opt::Instruction::OperandList{
           {SPV_OPERAND_TYPE_ID, {constant_true}},
           {SPV_OPERAND_TYPE_ID, {block_after_entry}},
-          {SPV_OPERAND_TYPE_LOOP_CONTROL, {message_.outer_header_id()}}}));
+          {SPV_OPERAND_TYPE_ID, {message_.outer_header_id()}}}));
 
   // Insert the header right after the entry block.
   function->InsertBasicBlockAfter(std::move(outer_loop_header),
diff --git a/test/fuzz/transformation_flatten_conditional_branch_test.cpp b/test/fuzz/transformation_flatten_conditional_branch_test.cpp
index 9f9027b..d71314b 100644
--- a/test/fuzz/transformation_flatten_conditional_branch_test.cpp
+++ b/test/fuzz/transformation_flatten_conditional_branch_test.cpp
@@ -1725,6 +1725,16 @@
   ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
                                                kConsoleMessageConsumer));
 
+  // Check that the in operands of any OpSelect instructions all have the
+  // appropriate operand type.
+  context->module()->ForEachInst([](opt::Instruction* inst) {
+    if (inst->opcode() == SpvOpSelect) {
+      ASSERT_EQ(SPV_OPERAND_TYPE_ID, inst->GetInOperand(0).type);
+      ASSERT_EQ(SPV_OPERAND_TYPE_ID, inst->GetInOperand(1).type);
+      ASSERT_EQ(SPV_OPERAND_TYPE_ID, inst->GetInOperand(2).type);
+    }
+  });
+
   std::string expected_shader = R"(
                OpCapability Shader
           %1 = OpExtInstImport "GLSL.std.450"
diff --git a/test/fuzz/transformation_merge_function_returns_test.cpp b/test/fuzz/transformation_merge_function_returns_test.cpp
index 9eb535f..e60d345 100644
--- a/test/fuzz/transformation_merge_function_returns_test.cpp
+++ b/test/fuzz/transformation_merge_function_returns_test.cpp
@@ -1837,6 +1837,16 @@
   ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
                                                kConsoleMessageConsumer));
 
+  // Ensure that all input operands of OpBranchConditional instructions have
+  // the right operand type.
+  context->module()->ForEachInst([](opt::Instruction* inst) {
+    if (inst->opcode() == SpvOpBranchConditional) {
+      ASSERT_EQ(inst->GetInOperand(0).type, SPV_OPERAND_TYPE_ID);
+      ASSERT_EQ(inst->GetInOperand(1).type, SPV_OPERAND_TYPE_ID);
+      ASSERT_EQ(inst->GetInOperand(2).type, SPV_OPERAND_TYPE_ID);
+    }
+  });
+
   std::string after_transformation = R"(
                OpCapability Shader
           %1 = OpExtInstImport "GLSL.std.450"