]> gcc.gnu.org Git - gcc.git/commit
RISC-V: Bugfix for RVV overloaded intrinisc ICE when empty args
authorPan Li <pan2.li@intel.com>
Tue, 6 Feb 2024 07:35:02 +0000 (15:35 +0800)
committerPan Li <pan2.li@intel.com>
Wed, 7 Feb 2024 01:18:29 +0000 (09:18 +0800)
commitdb5c3f6d952bc3950d23c0a6be4e8ec9147ef752
tree8843dd637c74d4cf395708196ec2e579a3057244
parent3e4c4c5edf6114c2188066ba595202cf05c81147
RISC-V: Bugfix for RVV overloaded intrinisc ICE when empty args

There is one corn case when similar as below example:

void test (void)
{
  __riscv_vfredosum_tu ();
}

It will meet ICE because of the implement details of overloaded function
in gcc.  According to the rvv intrinisc doc, we have no such overloaded
function with empty args.  Unfortunately, we register the empty args
function as overloaded for avoiding conflict.  Thus, there will be actual
one register function after return NULL_TREE back to the middle-end,
and finally result in ICE when expanding.  For example:

1. First we registered void __riscv_vfredmax () as the overloaded function.
2. Then resolve_overloaded_builtin (this func) return NULL_TREE.
3. The functions register in step 1 bypass the args check as empty args.
4. Finally, fall into expand_builtin with empty args and meet ICE.

Here we report error when overloaded function with empty args.  For example:

test.c: In function 'foo':
test.c:8:3: error: no matching function call to '__riscv_vfredosum_tu' with empty args
    8 |   __riscv_vfredosum_tu();
      |   ^~~~~~~~~~~~~~~~~~~~

Below test are passed for this patch.

* The riscv regression tests.

PR target/113766

gcc/ChangeLog:

* config/riscv/riscv-protos.h (resolve_overloaded_builtin): Adjust
the signature of func.
* config/riscv/riscv-c.cc (riscv_resolve_overloaded_builtin): Ditto.
* config/riscv/riscv-vector-builtins.cc (resolve_overloaded_builtin): Make
overloaded func with empty args error.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr113766-1.c: New test.
* gcc.target/riscv/rvv/base/pr113766-2.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/config/riscv/riscv-c.cc
gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv-vector-builtins.cc
gcc/testsuite/gcc.target/riscv/rvv/base/pr113766-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/pr113766-2.c [new file with mode: 0644]
This page took 0.062076 seconds and 6 git commands to generate.