-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Description
_ZGVsMxvv_powf returns incorrect values depending on the predicate.
Test program:
#include <stdio.h>
#include <mathlib.h>
int main() {
svint32_t i = svindex_s32(2, 1); // 2, 3, 4, 5
svfloat32_t x = svcvt_f32_s32_x(svptrue_b32(), i); // 2.0, 3.0, 4.0, 5.0
svfloat32_t y = svdup_n_f32(2.0f); // 2.0, 2.0, 2.0, 2.0
svbool_t p = svptrue_b32(); // T, T, T, T
svfloat32_t z = _ZGVsMxvv_powf(x, y, p); // 4.0, 9.0, 16.0, 25.0
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL1), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL2), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL3), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL4), z));
printf("----\n");
p = svptrue_pat_b32(SV_VL2); // T, T, F, F
z = _ZGVsMxvv_powf(x, y, p); // 4.0, 9.0, ---, ---
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL1), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL2), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL3), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL4), z));
printf("----\n");
p = svnot_z(svptrue_b32(), p); // F, F, T, T
z = _ZGVsMxvv_powf(x, y, p); // ---, ---, 16.0, 25.0
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL1), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL2), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL3), z));
printf("%f\n", svlastb(svptrue_pat_b32(SV_VL4), z));
printf("----\n");
return 0;
}Compilation and execution:
$ gcc -march=armv8.2-a+sve -I$AOR/include -L$AOR/lib svepowf.c -lmathlib -lm
$ ./a.outExpected output:
4.000000
9.000000
16.000000
25.000000
----
4.000000
9.000000
nan
nan
----
nan
nan
16.000000
25.000000
----
Actual output:
4.000000
9.000000
16.000000
25.000000
----
4.000000
1.000000
nan
nan
----
nan
nan
1.000000
25.000000
----
My environment:
- CPU: Grace (Neoverse V2)
- OS: Ubuntu 24.04 (AArch64)
- AOR: commit cbe9f6b (latest
masterbranch) - Compiler: GCC 13.3.0 and Clang/LLVM latest development branch
It seems libmvec in Glibc (at least version 2.41 in Ubuntu 25.04) also has this bug.
Metadata
Metadata
Assignees
Labels
No labels