[llvm] [SPIRV] Add support for SPV_KHR_bit_instructions (PR #66215)

Ilia Diachkov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 13:51:44 PDT 2023


================
@@ -884,6 +902,12 @@ 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::Shader,
+                          SPIRV::Capability::BitInstructions);
----------------
iliya-diyachkov wrote:

Well, but your implementation removes `Shader` in the presence of `BitInstructions` which is not expected according to your description, right?

Also it would be nice to have a test on this feature (not required in this patch).

By the way SPIRV translator leaves both capabilities. I added your test to another existing test in translator's test base and ran it with -spirv-ext=+SPV_KHR_bit_instructions. Here is the result:
```
...
               OpCapability Matrix
               OpCapability Shader
               OpCapability Addresses
               OpCapability Linkage
               OpCapability Kernel
               OpCapability BitInstructions
               OpExtension "SPV_KHR_bit_instructions"
...
```
However I agree that it's excessive. I haven't updated the translator for a long time, so maybe this behavior has already changed.

https://github.com/llvm/llvm-project/pull/66215


More information about the llvm-commits mailing list