KhronosGroup / SPIRV-Tools

Apache License 2.0
1.05k stars 549 forks source link

opt: invalid SPIR-V produced: OpPhi's number of incoming blocks (3) does not match block's predecessor count (4). #2712

Closed paulthomson closed 5 years ago

paulthomson commented 5 years ago

bug_report.zip

Issue found using GraphicsFuzz.

Tool versions:

To reproduce:

glslangValidator -V shader.comp -o shader.comp.spv

spirv-opt shader.comp.spv -o temp.spv --validate-after-all --private-to-local --eliminate-local-multi-store --simplify-instructions --eliminate-dead-inserts --eliminate-dead-branches --merge-return

The following shader files are included in the attached archive, some of which are also shown inline below:

0_glsl/shader.comp:

#version 310 es

precision highp float;

layout(std430, binding = 0) buffer doesNotMatter {
 vec4 _compute_data[];
} ;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 10) in;
float nb_mod()
{
 float s;
 s = 0.0;
 for(
     int i = 1;
     i < 800;
     1
 )
  {
   int GLF_live1_looplimiter2;
   for(
       int GLF_live1i = 0;
       true;
       1
   )
    {
     if(GLF_live1_looplimiter2 >= 5)
      {
       break;
       return 1.0;
      }
     return 1.0;
    }
   if(float(i) <= 0.01)
    {
     break;
    }
   return 1.0;
  }
 return s;
}
void main()
{
 nb_mod();
}
s-perron commented 5 years ago

Duplicate of #2702.