diff options
author | Robin Dapp <rdapp@ventanamicro.com> | 2023-08-18 16:16:54 +0200 |
---|---|---|
committer | Robin Dapp <rdapp@ventanamicro.com> | 2023-08-24 13:12:49 +0200 |
commit | b6ba0cc9339f2cc81398863ae779daa6c8853ad6 (patch) | |
tree | dbc4e1ceff58706f770b1678fcf3457be2fca2e2 /gcc | |
parent | e7aec3ae38ce740885e73255e12675174790758d (diff) | |
download | gcc-b6ba0cc9339f2cc81398863ae779daa6c8853ad6.zip gcc-b6ba0cc9339f2cc81398863ae779daa6c8853ad6.tar.gz gcc-b6ba0cc9339f2cc81398863ae779daa6c8853ad6.tar.bz2 |
RISC-V: Allow const 17-31 for vector shift.
This patch adds a missing constraint in order to be able to print (and
not ICE) vector immediates 17-31 for vector shifts.
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_print_operand): Allow vk operand.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/binop/shift-immediate.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/riscv/riscv.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 49062be..0f60ffe 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4954,7 +4954,8 @@ riscv_print_operand (FILE *file, rtx op, int letter) else if (satisfies_constraint_Wc0 (op)) asm_fprintf (file, "0"); else if (satisfies_constraint_vi (op) - || satisfies_constraint_vj (op)) + || satisfies_constraint_vj (op) + || satisfies_constraint_vk (op)) asm_fprintf (file, "%wd", INTVAL (elt)); else output_operand_lossage ("invalid vector constant"); diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c new file mode 100644 index 0000000..a2e1c33 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-immediate.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c99 -march=rv32gcv -mabi=ilp32d -O2 --param=riscv-autovec-preference=scalable" } */ + +#define uint8_t unsigned char + +void foo1 (uint8_t *a) +{ + uint8_t b = a[0]; + int val = 0; + + for (int i = 0; i < 4; i++) + { + a[i] = (val & 1) ? (-val) >> 17 : val; + val += b; + } +} |