[llvm-bugs] [Bug 47705] New: Inefficient code generated for matrix initialization loop

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 1 11:24:10 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47705

            Bug ID: 47705
           Summary: Inefficient code generated for matrix initialization
                    loop
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: florian_hahn at apple.com
                CC: llvm-bugs at lists.llvm.org

As reported on the mailing list
(http://lists.llvm.org/pipermail/llvm-dev/2020-September/145367.html) and
discord, GCC beats LLVM on the code below by 4x reportedly

https://godbolt.org/z/4G1rh1


#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);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201001/700774d7/attachment-0001.html>


More information about the llvm-bugs mailing list