Skip to content

[clang][LoongArch] LSX/LASX headers do not work with -fno-lax-vector-conversions #110834

Closed
@xen0n

Description

@xen0n

The current Clang LSX/LASX intrinsics header files make heavy use of implicit vector conversions vector bitcasts, that is not accepted by Clang 18+ (Clang 17 does not support Loongson SIMD) with -fno-lax-vector-conversions. Example:

// clang -c -fno-lax-vector-conversions -mlsx test-lsx-lax-conversion.c
#include <lsxintrin.h>
int main(void) { return 0; }
In file included from test-lsx-lax-conversion.c:1:
/usr/lib/llvm/19/bin/../../../../lib/clang/19/include/lsxintrin.h:42:40: error: cannot initialize a parameter of type '__attribute__((__vector_size__(16 * sizeof(char)))) char' (vector of 16 'char' values) with an rvalue of type 'v16i8' (vector of 16 'signed char' values)
   42 |   return (__m128i)__builtin_lsx_vsll_b((v16i8)_1, (v16i8)_2);
      |                                        ^~~~~~~~~
[lots of similar errors omitted]

It complicates distribution packaging for certain software, because

  1. they require or work better with Clang, and
  2. effectively one is forced to enable -flax-vector-conversions here and there, for example Skia.

So it may be best to just fix the headers to work with strict vector conversion checks, to stop the proliferation of lax coding practice.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions