Address Richard's comment. Thanks Jim
Richard Sandiford <richard.sandif...@arm.com> 於 2024年12月30日 週一 下午7:50寫道: > > Tsung Chun Lin <tclin...@gmail.com> writes: > > From ddb7852c92dc0222af9eeec1deafce753b3a7067 Mon Sep 17 00:00:00 2001 > > From: Jim Tsung-Chun Lin <j...@andestech.com> > > Date: Mon, 30 Dec 2024 15:32:12 +0800 > > Subject: [PATCH] Prefer scalar_int_mode if the size - 1 is equal to > > UNITS_PER_WORD. > > > > Don't use the QI vector if its size is equal to UNITS_PER_WORD for > > better code generation. > > That makes sense, but... > > > Before patch: > > > > vsetivli zero,4,e8,mf4,ta,ma > > vmv.v.i v1,0 > > addi a4,sp,12 > > vse8.v v1,0(a4) > > > > After patch: > > > > sw zero,12(sp) > > --- > > gcc/expr.cc | 2 +- > > gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c | 1 - > > 2 files changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/gcc/expr.cc b/gcc/expr.cc > > index babf00f34dc..e2abef1f544 100644 > > --- a/gcc/expr.cc > > +++ b/gcc/expr.cc > > @@ -1062,7 +1062,7 @@ widest_fixed_size_mode_for_size (unsigned int size, > > by_pieces_operation op) > > gcc_checking_assert (size > 1); > > > > /* Use QI vector only if size is wider than a WORD. */ > > - if (can_use_qi_vectors (op) && size > UNITS_PER_WORD) > > + if (can_use_qi_vectors (op) && (size - 1) > UNITS_PER_WORD) > > ...it looks like this will still use UNITS_PER_WORD QI vectors for > size == UNITS_PER_WORD + 2. > > How about instead removing the size > UNITS_PER_WORD check above and > instead checking: > > if (is_a<fixed_size_mode> (mode, &candidate) > && GET_MODE_SIZE (candidate) > UNITS_PER_WORD > && GET_MODE_INNER (candidate) == QImode) > > in the loop (with the second line being new)? > > Thanks, > Richard > > > { > > machine_mode mode; > > fixed_size_mode candidate; > > diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c > > b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c > > index 52e2580c53e..6549ae61c67 100644 > > --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c > > +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c > > @@ -51,5 +51,4 @@ void p(int buf, __builtin_va_list ab, int q) { > > } while (k); > > } > > > > -/* { dg-final { scan-assembler-times > > {vsetivli\tzero,\s*4,\s*e8,\s*mf4,\s*t[au],\s*m[au]} 1 } } */ > > /* { dg-final { scan-assembler-times > > {vsetivli\tzero,\s*8,\s*e8,\s*mf2,\s*t[au],\s*m[au]} 1 } } */
0001-Prefer-scalar_int_mode-if-the-size-of-QI-vector-is-e.patch
Description: Binary data