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: [email protected]
Reporter: [email protected]
CC: [email protected]
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._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs