https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116592
--- Comment #5 from Jin Ma <jinma at linux dot alibaba.com> --- (In reply to nihui from comment #0) > $ ./riscv64-unknown-linux-gnu-g++ -c test3.c -o test3.o > -march=rv64gc_zfh_xtheadvector -O2 > /tmp/ccQPGUNc.s: Assembler messages: > /tmp/ccQPGUNc.s:86: Error: illegal operands `th.vsetvli zero,0,e32,m8' > > > -O1 compiles fine > -O2 and -O3 gives the above error > > > > > $ ./riscv64-unknown-linux-gnu-g++ -v > Using built-in specs. > COLLECT_GCC=./riscv64-unknown-linux-gnu-g++ > COLLECT_LTO_WRAPPER=/data/action/osd/riscv/libexec/gcc/riscv64-unknown-linux- > gnu/15.0.0/lto-wrapper > Target: riscv64-unknown-linux-gnu > Configured with: /data/action/osd/riscv-gnu-toolchain/gcc/configure > --target=riscv64-unknown-linux-gnu --prefix=/data/action/osd/riscv > --with-sysroot=/data/action/osd/riscv/sysroot --with-pkgversion=g155da081706 > --with-system-zlib --enable-shared --enable-tls > --enable-languages=c,c++,fortran --disable-libmudflap --disable-libssp > --disable-libquadmath --disable-libsanitizer --disable-nls > --disable-bootstrap --src=.././gcc --disable-default-pie --disable-multilib > --with-abi=lp64d --with-arch=rv64imafdc --with-tune=rocket > --with-isa-spec=20191213 'CFLAGS_FOR_TARGET=-O2 -mcmodel=medlow' > 'CXXFLAGS_FOR_TARGET=-O2 -mcmodel=medlow' > Thread model: posix > Supported LTO compression algorithms: zlib > gcc version 15.0.0 20240829 (experimental) (g155da081706) > > > > binutils master branch > > commit 5cca20f614694ba6af3c10ca5bb93c32cdb9522b (HEAD -> master, > origin/master, origin/HEAD) > Author: GDB Administrator <gdbad...@sourceware.org> > Date: Thu Aug 29 00:00:14 2024 +0000 > > Automatic date update in version.in > > > > ------------- soucecode ------------- > > > #include <math.h> > #include <riscv_vector.h> > > static vfloat32m8_t atan2_ps(vfloat32m8_t a, vfloat32m8_t b, size_t vl) > { > float tmpx[vl]; > float tmpy[vl]; > __riscv_vse32_v_f32m8(tmpx, a, vl); > __riscv_vse32_v_f32m8(tmpy, b, vl); > for (size_t i = 0; i < vl; i++) > { > tmpx[i] = atan2(tmpx[i], tmpy[i]); > } > return __riscv_vle32_v_f32m8(tmpx, vl); > } > > void my_atan2(const float* x, const float* y, float* out, int size) > { > int n = size; > while (n > 0) > { > size_t vl = __riscv_vsetvl_e32m8(n); > vfloat32m8_t _x = __riscv_vle32_v_f32m8(x, vl); > vfloat32m8_t _y = __riscv_vle32_v_f32m8(y, vl); > vfloat32m8_t _out = atan2_ps(_x, _y, vl); > __riscv_vse32_v_f32m8(out, _out, vl); > n -= vl; > x += vl; > y += vl; > out += vl; > } > } I tried to fix this issue, see the patch below link: https://gcc.gnu.org/pipermail/gcc-patches/2024-September/662463.html BR Jin