Skip to content

Writing to a global matrix in back-compat mode causes compiler to crash in some cases #1530

Description

While enabling support for writing to globals with /Gec flag (#1526 ), the below test causes the compiler to crash when writing to a matrix is enabled. It's likely bad code gen.

float g_s;
float4 g_v = float4(1.0, -1.0, 0.0, 1.0);
// TODO: writing to a global matrix currently causes the compiler to crash. fix it.
// int2x2 g_m;
bool g_b = false;
int g_a[5];
int g_a2d[3][2];
float4 main(uint a
            : A) : SV_Target {
  // update global scalar
  g_s = a;

  // update global vector
  g_v = float4(a + 1, a + 2, a + 3, a + 4);

  /*
  // update global matrix
  for (uint i = 0; i < 2; i++)
    for (uint j = 0; j < 2; j++)
      g_m[i][j] = a + i + j;
  */
  
  // update global 2d array
  for (uint i = 0; i < 3; i++)
    for (uint j = 0; j < 2; j++)
      g_a2d[i][j] = a + i + j;

  // update global array
  for (uint i = 0; i < 5; i++)
    g_a[i] = a + i;

  // update global boolean
  g_b = true;

  return float4(g_s, g_s, g_s, g_s) +
         g_v +
         // float4(g_m[0][0], g_m[0][1], g_m[1][0], g_m[1][1]) +
         float4(g_a2d[0][0], g_a2d[0][1], g_a2d[1][0], g_a2d[1][1]) +
         float4(g_a[0], g_a[1], g_a[2], g_a[3]);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugBug, regression, crash

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions