[GLSL 4.30 BUG] Compiled Assembler code different from expected assembler code

Bug Report: I compiled a shader, but I got strange results when using it.
So I looked at its assembly code, which I got from NVemulate.
But from the assembly, I can see that the compiled code is slightly faulty.
The shader has not been correctly compiled. Details below:

  1. Operating system version.
    Windows 10 Pro
    Version: 1607
    OS Build: 14393.969

  2. Graphics hardware.
    Nvidia GeForce GTX 1070

  3. Graphics driver version.
    21.21.13.7866

  4. Display Control Panel settings for screen resolution, monitor configs, and driver settings.

This below is the output from the Nvidia Control Panel:

[Display]
Operating System: Windows 10 Pro, 64-bit
DirectX version: 12.0
GPU processor: GeForce GTX 1070
Driver version: 378.66
Direct3D API version: 12
Direct3D feature level: 12_1
CUDA Cores: 1920
Core clock: 1506 MHz
Memory data rate: 8008 MHz
Memory interface: 256-bit
Memory bandwidth: 256.26 GB/s
Total available graphics memory: 24544 MB
Dedicated video memory: 8192 MB GDDR5
System video memory: 0 MB
Shared system memory: 16352 MB
Video BIOS version: 86.04.26.00.61
IRQ: Not used
Bus: PCI Express x16 Gen3
Device ID: 10DE 1B81 85981043
Part Number: G411 0020

  1. Reproducer project.

A compiled executable that reproduces the issue can be found here:
https://github.com/Erkaman/nvidia-bug-report/blob/master/bins/demo.exe
download the repo, and run the exe.

It simply compiles the shader consisting of the vertex shader “vert.glsl” and the fragment shader “frag.glsl”
Code here:
https://github.com/Erkaman/nvidia-bug-report/blob/master/bins/frag.glsl
https://github.com/Erkaman/nvidia-bug-report/blob/master/bins/vert.glsl

Source code of the exe is here:
https://github.com/Erkaman/nvidia-bug-report/blob/master/src/main.cpp

All dependencies are in the repo. Use cmake to build a visual studio project, and doing so you
can compile the file.

  1. Description of single steps to reproduce the problem.

Run demo.exe, with “Write Program Object Assembly” enabled in NVEmulate.
Now, the assembly of frag.glsl shall be outputted to fasm_3_0.txt by NVEmulate.

Now look at fasm_3_0.txt:
https://github.com/Erkaman/nvidia-bug-report/blob/master/bins/fasm_3_0.txt

Notice the last lines:


ENDREP;
MOV.F result_color0, {0, 0.200000003, 1, 0}.xyxz;
END

So, the only possible output color of the shader is vec3(0, 0.2,0).
But that shouldn’t be. The output color vec3(0.2, 0,0) should also be possible,
but that has been completely removed from the compiled shader.
See the comment in frag.glsl for more details:
https://github.com/Erkaman/nvidia-bug-report/blob/master/bins/frag.glsl

  1. Description of the expected result (screenshots if possible).

If we in frag.glsl change from

if(nodePointer == NULL_NODE) { outColor = vec3(0.2, 0,0); return;}
outColor = vec3(0, 0.2,0);return;

to

if(nodePointer == NULL_NODE) { outColor = vec3(0.2, 0,0); return;}
else outColor = vec3(0, 0.2,0);return;

at line 59, the compiled assembly becomes different. The ending lines are now instead:


IF NE.x;
MOV.F R0.xyz, {0.200000003, 0, 0, 0}.xyyw;
ELSE;
MOV.F R0.xyz, {0, 0.200000003, 0, 0}.xyxw;
ENDIF;
MOV.F result_color0.xyz, R0;
MOV.F result_color0.w, {1, 0, 0, 0}.x;

Which is the expected result, from compiling that shader frag.glsl. So this is what
we should be getting, but we are not getting.