[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:17:28 PDT 2023


pmatos wrote:

> Why do you think, it is a mistake? Well, SPIRV translator emits both capabilities in the original test. However, I built the test without `OpCapability Shader` in SPIRV asm, and SPIRV validator didn't report errors... If I remove the both capabilities, the validator reports the error:
> 
> ```
> error: line 34: Opcode BitReverse requires one of these capabilities: Shader BitInstructions 
>   %call = OpBitReverse %uint %b
> ```

I initially added this code but I think I misinterpreted the purpuse of `AvailableCaps`. We are _not_ removing both capabilities. We are just not removing BitInstructions. We make sure they are both _available_. 

Now all relevant tests pass. If we use bit instructions but no instructions that require shader we use the bit instructions extension. If we use instructions that require shader as well, we use the shader extension but not bit instructions. We just make sure they are exclusive to each other. The test `llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_bit_instructions.ll` should be self-explanatory.

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


More information about the llvm-commits mailing list