https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123766
Bug ID: 123766
Summary: LoongArch: __lsx_vst and _lasx_xvst may trigger
maybe-uninitialized warning for its second argument
Product: gcc
Version: 14.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: iv at altlinux dot org
Target Milestone: ---
__lsx_vst is a LSX intrinsic that writes to the memory pointed to by its second
argument (+offset). But under some circumstances passing uninitialized array to
__lsx_vst triggers maybe-uninitialized warning, which is strange, since the
corresponding instruction does not use the memory, only writes there.
$ cat test_lsx_vst.c
#include <lsxintrin.h>
v2i64 v = {0, 0};
static inline
void try_store() {
long r[2];
__lsx_vst(v, r, 0);
}
int main()
{
try_store();
}
$ loongarch64-linux-gnu-gcc -O2 -mlasx -Werror -Wextra test_lsx_vst.c
In file included from test_lsx_vst.c:1:
In function 'try_store',
inlined from 'main' at test_lsx_vst.c:13:3:
test_lsx_vst.c:8:3: error: 'r' may be used uninitialized
[-Werror=maybe-uninitialized]
8 | __lsx_vst(v, r, 0);
| ^~~~~~~~~
<built-in>: In function 'main':
<built-in>: note: by argument 2 of type 'const volatile void *' to
'__builtin_lsx_vst' declared here
test_lsx_vst.c:7:8: note: 'r' declared here
7 | long r[2];
| ^
cc1: all warnings being treated as errors
I'm using gcc 14.3.1, but the issue is reproducible on all the GCC versions
available for loongarch64 on godbolt.org.
The same issue is reproducible for the corresponding LASX intrinsic,
__lasx_xvst:
$ cat test_lasx_xvst.c
#include <lasxintrin.h>
v4i64 v = {0, 0, 0, 0};
static inline
void try_store() {
long r[4];
__lasx_xvst(v, r, 0);
}
int main()
{
try_store();
}
$ loongarch64-linux-gnu-gcc -O2 -mlasx -Werror -Wextra test_lasx_xvst.c
In file included from test_lasx_xvst.c:1:
In function 'try_store',
inlined from 'main' at test_lasx_xvst.c:13:3:
test_lasx_xvst.c:8:3: error: 'r' may be used uninitialized
[-Werror=maybe-uninitialized]
8 | __lasx_xvst(v, r, 0);
| ^~~~~~~~~~~
<built-in>: In function 'main':
<built-in>: note: by argument 2 of type 'const volatile void *' to
'__builtin_lasx_xvst' declared here
test_lasx_xvst.c:7:8: note: 'r' declared here
7 | long r[4];
| ^
cc1: all warnings being treated as errors