Possible miscompilation of an integer division with vulkan
System information
System: Kernel: 5.11.0-18-generic x86_64 bits: 64 compiler: gcc v: 10.2.1 Desktop: GNOME 3.38.4
tk: GTK 3.24.25 wm: gnome-shell dm: GDM3 Distro: Ubuntu 21.04 (Hirsute Hippo)
CPU: Info: 6-Core model: Intel Core i7-8750H bits: 64 type: MT MCP arch: Kaby Lake note: check rev: A L2 cache: 9 MiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 52799
Speed: 900 MHz min/max: 800/4100 MHz Core speeds (MHz): 1: 900 2: 900 3: 900 4: 900 5: 900 6: 900 7: 900 8: 901
9: 900 10: 900 11: 900 12: 900
Graphics: Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] vendor: ASUSTeK driver: i915 v: kernel bus ID: 00:02.0
chip ID: 8086:3e9b
Renderer:Intel, Vulkan 1.2.168 (Intel(R) UHD Graphics 630 (CFL GT2) (0x00003E9B)), Intel open-source Mesa driver-21.1.7
Describe the issue
The following code containing an affectation does not perform the division by "-1" with the vulkan driver.
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(std430, binding = 0) buffer buffer_0 {
int ext_1; // 2
int ext_2; // 4
};
void main()
{
ext_2 /= -(1 + 1 / ext_1);
}
At the end of the execution, the shader storage block contains:
2 4
I would expect the shader storage block to contain instead:
2 -4
Reproducing the issue
Two Vkrunner codes are linked, the first one contains a copy of this shader shader09.shader_test, the second contains the generated spirv code obtained with glslangValidator shader09_spirv.shader_test.
Please let me know if necessary information about my system is missing or if you prefer another format for the files (Amber? ).