-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to compile matrix product like code using llvm 19.x for riscv vector extension. #121086
Comments
@llvm/issue-subscribers-backend-risc-v Author: Huaqi Fang (fanghuaqi)
Hi there,
I tried to compile source code as below, using clang with options: float *matA, *matB, *matC;
int nthreads = 1;
typedef struct{
int id;
int rowsA;
int colsA;
int colsB;
} tArgs;
void CalculaProdutoMatriz(void *arg) {
int i, j, k;
tArgs *args = (tArgs*) arg;
int rowsA = args->rowsA;
int colsA = args->colsA;
int colsB = args->colsB;
for(i = args->id; i < rowsA; i += nthreads) {
for(j = 0; j < colsB; j++) {
matC[i * colsB + j] = 0;
for(k = 0; k < colsA; k++) {
matC[i * colsB + j] += matA[i * colsA + k] * matB[k * colsB + j];
}
}
}
} It works in llvm 18.x and llvm truck(20.x), but failed in llvm 19.x error message like this
Thanks |
The error says the |
I didn't paste the complete source code, I compiled it in my SDK environment, I create compiler explorer link here https://godbolt.org/z/Ec3o8vex1 It contains a main function. I just want to test the auto vectorization for riscv vector in llvm clang. |
Can you be more specific about the baseline of 19.x? I can't reproduce the error with: # clang -march=rv32imafc_zve32f_zvl128b -mabi=ilp32f -Ofast reduced.c -S
clang: warning: argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior, or '-O3' to enable only conforming optimizations [-Wdeprecated-ofast]
# clang -v
clang version 19.1.6 (e21dc4bd5474d04b8e62d7331362edcc5648d7e5)
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data00/wpc/software/llvm-dev/bin
Build config: +unoptimized, +assertions OK, I can reproduce it with
The printed latest DAG is:
The LLVM IR of
I may take a detailed look later. |
Thanks @topperc @wangpc-pp , yes the error is |
When I changed the |
Reduced test:
I think #116159 can fix this error. |
Hi @wangpc-pp , this #116159 can fix this issue locally in my llvm compiler cherry picked this PR. |
Hi there,
I tried to compile source code as below, using clang with options:
-march=rv32imafc_zve32f_zvl128b -mabi=ilp32f -Ofast
It works in llvm 18.x and llvm truck(20.x), but failed in llvm 19.x error message like this
Thanks
The text was updated successfully, but these errors were encountered: