@@ -226,6 +226,7 @@ OpCapability Int16
226226OpCapability Int64
227227OpCapability CooperativeMatrixKHR
228228OpExtension "SPV_KHR_cooperative_matrix"
229+ OpExtension "SPV_EXT_float8"
229230%1 = OpExtInstImport "GLSL.std.450"
230231OpMemoryModel Logical GLSL450
231232OpEntryPoint Fragment %main "main"
@@ -238,6 +239,8 @@ OpName %main "main"
238239%float = OpTypeFloat 32
239240%double = OpTypeFloat 64
240241%half = OpTypeFloat 16
242+ %float8e4m3 = OpTypeFloat 8 Float8E4M3EXT
243+ %float8e5m2 = OpTypeFloat 8 Float8E5M2EXT
241244%101 = OpConstantTrue %bool ; Need a def with an numerical id to define id maps.
242245%true = OpConstantTrue %bool
243246%false = OpConstantFalse %bool
@@ -444,6 +447,10 @@ OpName %main "main"
444447%half_null = OpConstantNull %half
445448%half_0_1 = OpConstantComposite %v2half %108 %half_1
446449%v4half_0_1_0_0 = OpConstantComposite %v4half %108 %half_1 %108 %108
450+ %float8e4m3_1 = OpConstant %float8e4m3 1.0
451+ %float8e4m3_0x1_4p_0 = OpConstant %float8e4m3 0x1.4p+0
452+ %float8e5m2_1 = OpConstant %float8e5m2 1.0
453+ %float8e5m2_0x1_4p_0 = OpConstant %float8e5m2 0x1.4p+0
447454%106 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
448455%v4float_0_0_0_0 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
449456%v4float_0_0_0_1 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1
@@ -1346,7 +1353,39 @@ INSTANTIATE_TEST_SUITE_P(TestCase, IntegerInstructionFoldingTest,
13461353 "%2 = OpBitReverse %uint %111\n" +
13471354 "OpReturn\n" +
13481355 "OpFunctionEnd",
1349- 2, 0)
1356+ 2, 0),
1357+ // Test case 98: Bit-cast float8e4m3 1 to float8e4m3
1358+ InstructionFoldingCase<uint32_t>(
1359+ Header() + "%main = OpFunction %void None %void_func\n" +
1360+ "%main_lab = OpLabel\n" +
1361+ "%2 = OpBitcast %float8e4m3 %float8e4m3_1\n" +
1362+ "OpReturn\n" +
1363+ "OpFunctionEnd",
1364+ 2, 0x38),
1365+ // Test case 99: Bit-cast float8e4m3 1 to ubyte
1366+ InstructionFoldingCase<uint32_t>(
1367+ Header() + "%main = OpFunction %void None %void_func\n" +
1368+ "%main_lab = OpLabel\n" +
1369+ "%2 = OpBitcast %ubyte %float8e4m3_0x1_4p_0\n" +
1370+ "OpReturn\n" +
1371+ "OpFunctionEnd",
1372+ 2, 0x3a), // FIXME: float8e4m3 1.4 is between 1.375 (0x3b) ~ 1.5 (0x3c)
1373+ // Test case 100: Bit-cast float8e5m2 1 to float8e5m2
1374+ InstructionFoldingCase<uint32_t>(
1375+ Header() + "%main = OpFunction %void None %void_func\n" +
1376+ "%main_lab = OpLabel\n" +
1377+ "%2 = OpBitcast %float8e5m2 %float8e5m2_1\n" +
1378+ "OpReturn\n" +
1379+ "OpFunctionEnd",
1380+ 2, 0x3c),
1381+ // Test case 101: Bit-cast float8e5m2 1 to ubyte
1382+ InstructionFoldingCase<uint32_t>(
1383+ Header() + "%main = OpFunction %void None %void_func\n" +
1384+ "%main_lab = OpLabel\n" +
1385+ "%2 = OpBitcast %ubyte %float8e5m2_0x1_4p_0\n" +
1386+ "OpReturn\n" +
1387+ "OpFunctionEnd",
1388+ 2, 0x3d) // FIXME: float8e5m2 1.4 is between 1.25 (0x3d) ~ 1.5 (0x3e)
13501389));
13511390// clang-format on
13521391
0 commit comments