Prefer scalar_int_mode if the size - 1 is equal to UNITS_PER_WORD.

Message ID 20250107182852.1871867-1-patrick@rivosinc.com
State New
Headers
Series Prefer scalar_int_mode if the size - 1 is equal to UNITS_PER_WORD. |

Checks

Context Check Description
rivoscibot/toolchain-ci-rivos-lint success Lint passed
rivoscibot/toolchain-ci-rivos-apply-patch success Patch applied
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-test success Testing passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply

Commit Message

Patrick O'Neill Jan. 7, 2025, 6:28 p.m. UTC
  From: Jim Tsung-Chun Lin <jim@andestech.com>

Re-sending this via git send-email to avoid the application/octet-stream
attachement type that prevents Patchworks/CI from finding the patch.

---

Don't use the QI vector if its size is equal to UNITS_PER_WORD for
better code generation.

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(-)
  

Patch

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)
     {
       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 } } */