RISC-V: Fix ICE and codegen error of scalar move in RV32 system.
commitdb4f7a9b47d148b5074ac15910124c746fb7a96f
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Wed, 29 Mar 2023 02:42:59 +0000 (29 10:42 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Sun, 2 Apr 2023 08:27:32 +0000 (2 16:27 +0800)
tree50961d3a341d685a95eeb15595d96b14942ea025
parent236cde7202aba9c8fee00035f6685fab1eecd808
RISC-V: Fix ICE and codegen error of scalar move in RV32 system.

We need to reset the AVL to 0 or 1 for scalar move for RV32 system,
For any non-zero AVL input, we set that to 1, and zero will keep as zero.

We are using wrong way (by andi with 1) before to achieve that, and it
will cause ICE with const_int, and also wrong behavior, so now we have
two code path, one for const_int and one for non-const_int.

bug.C:144:2: error: unrecognizable insn:
  144 |  }
      |  ^
(insn 684 683 685 26 (set (reg:SI 513)
        (and:SI (const_int 4 [0x4])
            (const_int 1 [0x1]))) "bug.C":115:47 -1
     (nil))

andi a4,a4,1 ===> sgtu a4,a4,zero
vsetlvi tu        vsetvli tu
vlse              vlse

gcc/ChangeLog:

* config/riscv/riscv-protos.h (gen_avl_for_scalar_move): New function.
* config/riscv/riscv-v.cc (gen_avl_for_scalar_move): New function.
* config/riscv/vector.md: Fix scalar move bug.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/scalar_move-6.c: Adapt test.
* gcc.target/riscv/rvv/base/scalar_move-9.c: New test.
gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv-v.cc
gcc/config/riscv/vector.md
gcc/testsuite/gcc.target/riscv/rvv/base/scalar_move-6.c
gcc/testsuite/gcc.target/riscv/rvv/base/scalar_move-9.c [new file with mode: 0644]