https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123759
chenglulu <chenglulu at loongson dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |chenglulu at loongson dot cn
--- Comment #1 from chenglulu <chenglulu at loongson dot cn> ---
(In reply to Ivan A. Melnikov from comment #0)
> __lsx_vftintrne_w_s converts a vector of 4 32-bit floats into a vector of 4
> 32-bit signed ints (v4i32). But it is defined as returning __m128i (a vector
> of two 64-bit signed ints currently), so assigning its result to v4i32 fails
> unless -flax-vector-conversions is specified:
>
> $ cat test-vftintrne_w_s.c
> #include <lsxintrin.h>
>
> void test(__m128 arg) {
> v4i32 tmp = __lsx_vftintrne_w_s(arg);
> }
> $ loongarch64-linux-gnu-gcc test-vftintrne_w_s.c
> test-vftintrne_w_s.c: In function 'test':
> test-vftintrne_w_s.c:5:5: note: use '-flax-vector-conversions' to permit
> conversions between vectors with differing element types or numbers of
> subparts
> 5 | v4i32 tmp = __lsx_vftintrne_w_s(arg);
> | ^~~~~
> test-vftintrne_w_s.c:5:17: error: incompatible types when initializing type
> 'v4i32' using type '__m128i'
> 5 | v4i32 tmp = __lsx_vftintrne_w_s(arg);
> | ^~~~~~~~~~~~~~~~~~~
>
>
> While this can be worked around with -flax-vector-conversions or an explicit
> cast, it would be nice if no workarounds would be required.
>
> I'm using GCC 14.3.1, but the issue is reproducible with all GCC 14 and 15
> versions for loongarch64 available at godbold.org, and seems to be present
> in current master.
Hi,
I believe that vector type conversions do indeed require explicit handling in
strict mode, primarily for type safety reasons, to prevent undefined behavior
that might result from implicit conversions. Therefore, I still recommend that
you perform explicit data type conversions when dealing with such issues, or
add the compiler option '-flax-vector-conversions'.
Thanks.