@@ -2486,6 +2486,104 @@ TEST_F(TrimCapabilitiesPassTest,
2486
2486
EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
2487
2487
}
2488
2488
2489
+ TEST_F (TrimCapabilitiesPassTest, Float16_RemovedWhenUnused) {
2490
+ const std::string kTest = R"(
2491
+ OpCapability Float16
2492
+ ; CHECK-NOT: OpCapability Float16
2493
+ OpCapability Shader
2494
+ OpMemoryModel Logical GLSL450
2495
+ OpEntryPoint GLCompute %1 "main"
2496
+ %void = OpTypeVoid
2497
+ %3 = OpTypeFunction %void
2498
+ %1 = OpFunction %void None %3
2499
+ %6 = OpLabel
2500
+ OpReturn
2501
+ OpFunctionEnd;
2502
+ )" ;
2503
+ const auto result =
2504
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2505
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
2506
+ }
2507
+
2508
+ TEST_F (TrimCapabilitiesPassTest, Float16_RemainsWhenUsed) {
2509
+ const std::string kTest = R"(
2510
+ OpCapability Float16
2511
+ ; CHECK: OpCapability Float16
2512
+ OpCapability Shader
2513
+ OpMemoryModel Logical GLSL450
2514
+ OpEntryPoint GLCompute %1 "main"
2515
+ %void = OpTypeVoid
2516
+ %float = OpTypeFloat 16
2517
+ %3 = OpTypeFunction %void
2518
+ %1 = OpFunction %void None %3
2519
+ %6 = OpLabel
2520
+ OpReturn
2521
+ OpFunctionEnd;
2522
+ )" ;
2523
+ const auto result =
2524
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2525
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
2526
+ }
2527
+
2528
+ TEST_F (TrimCapabilitiesPassTest, Int16_RemovedWhenUnused) {
2529
+ const std::string kTest = R"(
2530
+ OpCapability Int16
2531
+ ; CHECK-NOT: OpCapability Int16
2532
+ OpCapability Shader
2533
+ OpMemoryModel Logical GLSL450
2534
+ OpEntryPoint GLCompute %1 "main"
2535
+ %void = OpTypeVoid
2536
+ %3 = OpTypeFunction %void
2537
+ %1 = OpFunction %void None %3
2538
+ %6 = OpLabel
2539
+ OpReturn
2540
+ OpFunctionEnd;
2541
+ )" ;
2542
+ const auto result =
2543
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2544
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithChange);
2545
+ }
2546
+
2547
+ TEST_F (TrimCapabilitiesPassTest, Int16_RemainsWhenUsed) {
2548
+ const std::string kTest = R"(
2549
+ OpCapability Int16
2550
+ ; CHECK: OpCapability Int16
2551
+ OpCapability Shader
2552
+ OpMemoryModel Logical GLSL450
2553
+ OpEntryPoint GLCompute %1 "main"
2554
+ %void = OpTypeVoid
2555
+ %int = OpTypeInt 16 1
2556
+ %3 = OpTypeFunction %void
2557
+ %1 = OpFunction %void None %3
2558
+ %6 = OpLabel
2559
+ OpReturn
2560
+ OpFunctionEnd;
2561
+ )" ;
2562
+ const auto result =
2563
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2564
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
2565
+ }
2566
+
2567
+ TEST_F (TrimCapabilitiesPassTest, UInt16_RemainsWhenUsed) {
2568
+ const std::string kTest = R"(
2569
+ OpCapability Int16
2570
+ ; CHECK: OpCapability Int16
2571
+ OpCapability Shader
2572
+ OpMemoryModel Logical GLSL450
2573
+ OpEntryPoint GLCompute %1 "main"
2574
+ %void = OpTypeVoid
2575
+ %uint = OpTypeInt 16 0
2576
+ %3 = OpTypeFunction %void
2577
+ %1 = OpFunction %void None %3
2578
+ %6 = OpLabel
2579
+ OpReturn
2580
+ OpFunctionEnd;
2581
+ )" ;
2582
+ const auto result =
2583
+ SinglePassRunAndMatch<TrimCapabilitiesPass>(kTest , /* skip_nop= */ false );
2584
+ EXPECT_EQ (std::get<1 >(result), Pass::Status::SuccessWithoutChange);
2585
+ }
2586
+
2489
2587
} // namespace
2490
2588
} // namespace opt
2491
2589
} // namespace spvtools
0 commit comments