[llvm] [SPIRV] Do not remove capability from all caps (PR #68194)

Paulo Matos via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 06:04:21 PDT 2023


https://github.com/pmatos updated https://github.com/llvm/llvm-project/pull/68194

>From 01162da54c14441af62e41366dd3440536573f1a Mon Sep 17 00:00:00 2001
From: Paulo Matos <pmatos at igalia.com>
Date: Wed, 4 Oct 2023 11:34:21 +0200
Subject: [PATCH] [SPIRV] Do not remove capability from all caps

We were removing bit_instructions cap from All caps but this was a
mistake.

Test SPV_KHR_bit_instructions was failing. Remove function
removeCapabilityIf. It was not being done correctly and is now
unnecessary.
---
 llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp       | 13 -------------
 llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h         |  4 ----
 .../SPIRV/extensions/SPV_KHR_bit_instructions.ll    | 11 ++++-------
 3 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
index e8529496b07e4c4..0bda3fe3cf5a7fc 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
@@ -525,13 +525,6 @@ void SPIRV::RequirementHandler::addAvailableCaps(const CapabilityList &ToAdd) {
           SPIRV::OperandCategory::CapabilityOperand, Cap));
 }
 
-void SPIRV::RequirementHandler::removeCapabilityIf(
-    const Capability::Capability ToRemove,
-    const Capability::Capability IfPresent) {
-  if (AvailableCaps.contains(IfPresent))
-    AvailableCaps.erase(ToRemove);
-}
-
 namespace llvm {
 namespace SPIRV {
 void RequirementHandler::initAvailableCapabilities(const SPIRVSubtarget &ST) {
@@ -913,12 +906,6 @@ void addInstrRequirements(const MachineInstr &MI,
   default:
     break;
   }
-
-  // If we require capability Shader, then we can remove the requirement for
-  // the BitInstructions capability, since Shader is a superset capability
-  // of BitInstructions.
-  Reqs.removeCapabilityIf(SPIRV::Capability::BitInstructions,
-                          SPIRV::Capability::Shader);
 }
 
 static void collectReqs(const Module &M, SPIRV::ModuleAnalysisInfo &MAI,
diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
index 9eea9ac5bda5b08..b57a5f4c28278ac 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
@@ -113,10 +113,6 @@ struct RequirementHandler {
   bool isCapabilityAvailable(Capability::Capability Cap) const {
     return AvailableCaps.contains(Cap);
   }
-
-  // Remove capability ToRemove, but only if IfPresent is present.
-  void removeCapabilityIf(const Capability::Capability ToRemove,
-                          const Capability::Capability IfPresent);
 };
 
 using InstrList = SmallVector<MachineInstr *>;
diff --git a/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_bit_instructions.ll b/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_bit_instructions.ll
index 95395d5efb55d8b..c43f71d29028e5f 100644
--- a/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_bit_instructions.ll
+++ b/llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_bit_instructions.ll
@@ -1,5 +1,5 @@
-; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s --spirv-extensions=SPV_KHR_bit_instructions -o - | FileCheck %s --check-prefix=CHECK-EXTENSION
-; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-NO-EXTENSION
+; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s --spirv-extensions=SPV_KHR_bit_instructions -o - | FileCheck %s --check-prefixes=CHECK,CHECK-EXTENSION
+; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NO-EXTENSION
 
 ; CHECK-EXTENSION:      OpCapability BitInstructions
 ; CHECK-EXTENSION-NEXT: OpExtension "SPV_KHR_bit_instructions"
@@ -8,11 +8,8 @@
 ; CHECK-NO-EXTENSION-NOT: OpCabilitity BitInstructions
 ; CHECK-NO-EXTENSION-NOT: OpExtension "SPV_KHR_bit_instructions"
 
-
-; CHECK-EXTENSION: %[[#int:]] = OpTypeInt 32
-; CHECK-EXTENSION: OpBitReverse %[[#int]]
-; CHECK-NO-EXTENSION: %[[#int:]] = OpTypeInt 32
-; CHECK-NO-EXTENSION: OpBitReverse %[[#int]]
+; CHECK: %[[#int:]] = OpTypeInt 32
+; CHECK: OpBitReverse %[[#int]]
 
 define spir_kernel void @testBitRev(i32 %a, i32 %b, i32 %c, i32 addrspace(1)* nocapture %res) local_unnamed_addr {
 entry:



More information about the llvm-commits mailing list