<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Inefficient code generated for matrix initialization loop"
   href="https://bugs.llvm.org/show_bug.cgi?id=47705">47705</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inefficient code generated for matrix initialization loop
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>florian_hahn@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As reported on the mailing list
(<a href="http://lists.llvm.org/pipermail/llvm-dev/2020-September/145367.html">http://lists.llvm.org/pipermail/llvm-dev/2020-September/145367.html</a>) and
discord, GCC beats LLVM on the code below by 4x reportedly

<a href="https://godbolt.org/z/4G1rh1">https://godbolt.org/z/4G1rh1</a>


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define MILLION 1000000

struct Matrix {
  float E[4][4];
};

int main(void) {

  Matrix identity =
  {
    {{1, 0, 0, 0},
     {0, 1, 0, 0},
     {0, 0, 1, 0},
     {0, 0, 0, 1}}
  };


  int matrix_count = 10 * MILLION;
  Matrix *matrices = (Matrix *) malloc(matrix_count * sizeof(Matrix));

  clock_t begin = clock();
  for (int run = 0; run < 25; ++run) {
    for (int i = 0; i < matrix_count; ++i) {
      matrices[i] = identity;
    }
  }
  clock_t end = clock();
  printf("Value Check: %f\n", matrices[matrix_count / 2].E[2][2]);
  printf("Time in seconds: %f\n", (double)(end - begin) / CLOCKS_PER_SEC);
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>