@@ -211,6 +211,7 @@ TEST_P(IntegerInstructionFoldingTest, Case) {
211
211
#define UINT_0_ID 109
212
212
#define INT_NULL_ID 110
213
213
#define UINT_NULL_ID 111
214
+ #define HALF_3_ID 112
214
215
const std::string& Header() {
215
216
static const std::string header = R"(OpCapability Shader
216
217
OpCapability Float16
@@ -405,8 +406,11 @@ OpName %main "main"
405
406
%v2double_2_0p5 = OpConstantComposite %v2double %double_2 %double_0p5
406
407
%v2double_null = OpConstantNull %v2double
407
408
%108 = OpConstant %half 0
409
+ %half_0p5 = OpConstant %half 0.5
408
410
%half_1 = OpConstant %half 1
409
411
%half_2 = OpConstant %half 2
412
+ %112 = OpConstant %half 3
413
+ %half_null = OpConstantNull %half
410
414
%half_0_1 = OpConstantComposite %v2half %108 %half_1
411
415
%106 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
412
416
%v4float_0_0_0_0 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
@@ -1683,7 +1687,7 @@ TEST_P(FloatVectorInstructionFoldingTest, Case) {
1683
1687
// clang-format off
1684
1688
INSTANTIATE_TEST_SUITE_P(TestCase, FloatVectorInstructionFoldingTest,
1685
1689
::testing::Values(
1686
- // Test case 0: FMix {2.0, 2 .0}, {2 .0, 3 .0} {0.2,0.5}
1690
+ // Test case 0: FMix {2.0, 3 .0}, {0 .0, 0 .0} {0.2,0.5}
1687
1691
InstructionFoldingCase<std::vector<float>>(
1688
1692
Header() + "%main = OpFunction %void None %void_func\n" +
1689
1693
"%main_lab = OpLabel\n" +
@@ -4930,6 +4934,38 @@ INSTANTIATE_TEST_SUITE_P(FloatRedundantFoldingTest, GeneralInstructionFoldingTes
4930
4934
"%2 = OpMatrixTimesScalar %float_coop_matrix %undef_float_coop_matrix %float_3\n" +
4931
4935
"OpReturn\n" +
4932
4936
"OpFunctionEnd",
4937
+ 2, 0),
4938
+ // Test case 32: Don't fold FMix half (1.0, 2.0, 0.5)
4939
+ InstructionFoldingCase<uint32_t>(
4940
+ Header() + "%main = OpFunction %void None %void_func\n" +
4941
+ "%main_lab = OpLabel\n" +
4942
+ "%2 = OpExtInst %half %1 FMix %half_1 %half_2 %half_0p5\n" +
4943
+ "OpReturn\n" +
4944
+ "OpFunctionEnd",
4945
+ 2, 0),
4946
+ // Test case 33: Fold FMix half (3.0, 2.0, 0.0)
4947
+ InstructionFoldingCase<uint32_t>(
4948
+ Header() + "%main = OpFunction %void None %void_func\n" +
4949
+ "%main_lab = OpLabel\n" +
4950
+ "%2 = OpExtInst %half %1 FMix %112 %half_2 %108\n" +
4951
+ "OpReturn\n" +
4952
+ "OpFunctionEnd",
4953
+ 2, HALF_3_ID),
4954
+ // Test case 34: Fold FMix half (3.0, 2.0, null)
4955
+ InstructionFoldingCase<uint32_t>(
4956
+ Header() + "%main = OpFunction %void None %void_func\n" +
4957
+ "%main_lab = OpLabel\n" +
4958
+ "%2 = OpExtInst %half %1 FMix %112 %half_2 %half_null\n" +
4959
+ "OpReturn\n" +
4960
+ "OpFunctionEnd",
4961
+ 2, HALF_3_ID),
4962
+ // Test case 35: Don't fold FMix half (1.0, 2.0, 1.0)
4963
+ InstructionFoldingCase<uint32_t>(
4964
+ Header() + "%main = OpFunction %void None %void_func\n" +
4965
+ "%main_lab = OpLabel\n" +
4966
+ "%2 = OpExtInst %half %1 FMix %half_1 %half_2 %half_1\n" +
4967
+ "OpReturn\n" +
4968
+ "OpFunctionEnd",
4933
4969
2, 0)
4934
4970
));
4935
4971
0 commit comments