https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127553

            Bug ID: 127553
           Summary: RISC-V: RVV builtin calls are not rejected when
                    building without RVV and the call can be optimized
                    away
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bunk at stusta dot de
  Target Milestone: ---

A CMake test of the snappy package in Debian wrongly reported RVV 1.0 support
due to:

$ cat test.cc
  #include <riscv_vector.h>
  #include <stdint.h>
  #include <stddef.h>
  int main() {
    uint8_t val = 3, dup[8];
    size_t vl = __riscv_vsetvl_e8m1(8);
    vuint8m1_t v = __riscv_vmv_v_x_u8m1(val, vl);
    return 0;
  }
$ g++ -march=rv64gc -c -Wall test.cc
test.cc: In function 'int main()':
test.cc:5:22: warning: unused variable 'dup' [-Wunused-variable]
    5 |     uint8_t val = 3, dup[8];
      |                      ^~~
test.cc:7:16: warning: unused variable 'v' [-Wunused-variable]
    7 |     vuint8m1_t v = __riscv_vmv_v_x_u8m1(val, vl);
      |                ^
test.cc:6:36: error: built-in function '__riscv_vsetvl_e8m1(8)' requires the
'v' ISA extension
    6 |     size_t vl = __riscv_vsetvl_e8m1(8);
      |                 ~~~~~~~~~~~~~~~~~~~^~~
test.cc:7:40: error: this operation requires the RVV ISA extension
    7 |     vuint8m1_t v = __riscv_vmv_v_x_u8m1(val, vl);
      |                    ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
test.cc:7:40: note: you can enable RVV using the command-line option '-march',
or by using the 'target' attribute or pragma
test.cc:7:40: error: built-in function '__riscv_vmv_v_x_u8m1(val, vl)' requires
the 'v' ISA extension
$ g++ -march=rv64gc -c -Wall -O2 test.cc
test.cc: In function 'int main()':
test.cc:5:22: warning: unused variable 'dup' [-Wunused-variable]
    5 |     uint8_t val = 3, dup[8];
      |                      ^~~
test.cc:7:16: warning: unused variable 'v' [-Wunused-variable]
    7 |     vuint8m1_t v = __riscv_vmv_v_x_u8m1(val, vl);
      |                ^
$

Seen with GCC 16, 15 and 14 (RVV 1.0 support was added in GCC 14).

Reply via email to