| Issue |
238995
|
| Summary |
[SPIR-V][Vulkan] Logical SPIR-V access chains use 64-bit indices
|
| Labels |
SPIR-V,
clang:HLSL:SPIRV
|
| Assignees |
dnovillo
|
| Reporter |
dnovillo
|
Clang declares `OpCapability Int64` in Vulkan modules whose HLSL source never uses a 64-bit integer, because it emits 64-bit access chain indices. The Vulkan validation layer then reports `VUID-VkShaderModuleCreateInfo-pCode-08740` for these modules unless the application enables the `shaderInt64` device feature. This affects several of the shaders in our internal testing.
To reproduce, compile this shader with `clang-dxc -spirv -T cs_6_6 -E main` at ToT:
```hlsl
struct S { float a, b; };
ConstantBuffer<S> CB : register(b0);
RWStructuredBuffer<float> Out : register(u0);
[numthreads(64,1,1)]
void main(uint i : SV_GroupIndex) {
float l[3] = { CB.a, CB.b, 0 };
Out[i] = l[i % 3];
}
```
In the output, the access chain for `CB.b` selects the member with a 64-bit `OpConstant`, and the one for `l[i % 3]` first widens the index with an `OpUConvert` to a 64-bit integer. DXC emits 32-bit indices for the same shader.
Index arithmetic is affected too, including loop counters used as indices.
>From what I can tell, three places choose 64 bits:
1. `SPIRVEmitIntrinsics` creates the literal indices of the access chains it rebuilds from byte-offset GEPs as `i64`.
2. The `spirv` triple's data layout has a 64-bit GEP index type.
3. Clang widens array subscripts to its 64-bit pointer width.
I'd like to fix this in two steps:
1. Create `i32` literal indices in `SPIRVEmitIntrinsics`, and error out on any past 2^31 - 1 (I have a PR in progress).
2. Give the `spirv` triple 32-bit pointers, `p:32:32`, as DXIL does, with a 32-bit pointer width in Clang.
@bogner, any concerns with moving the `spirv` triple to `p:32:32`?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs