mbox series

[0/2,RISC-V] c implies zca, and conditionally zcf & zcd

Message ID 20240705095631.949-1-gaofei@eswincomputing.com
Headers show
Series c implies zca, and conditionally zcf & zcd | expand

Message

Fei Gao July 5, 2024, 9:56 a.m. UTC
According to Zc-1.0.4-3.pdf from
https://github.com/riscvarchive/riscv-code-size-reduction/releases/tag/v1.0.4-3
The rule is that:
1. C always implies Zca
2. C+F implies Zcf (RV32 only)
3. C+D implies Zcd
Patch 2 handles this implication.

Without Patch 1, Patch 2 triggers an ICE when compiling 
gcc/testsuite/gcc.target/riscv/rvv/base/cpymem-1.c with -march=rv32imafcv.
The ICE is due to failure of gcc_assert (check_implied_ext ())
in riscv_subset_list::finalize ().
check_implied_ext checks if ALL implied extensions have been added
after handle_implied_ext.
In rv32imafcv case, handle_implied_ext first handles 'c'.
As there's no 'd' in subset list, zcd hasn't been added.
Then handle_implied_ext handles 'v'. 'v' implies 'zve64d',
and 'zve64d' implies 'd', so 'd' has been added into subset list.
However, after handle_implied_ext,
check_implied_ext finds 'c' and 'd' both available in subset
list, but 'zcd' is not here, causing assert failure. 

Patch 1 sovles the assert failure by calling handle_implied_ext
repeatly until there's no new subset added into the subset list.

This patch series also helps to expose the conflict between
c+d and zcmp/zcmt.

Regession tested rv64gc with no new failures.

Fei Gao (2):
  [RISC-V] add impied extension repeatly until stable
  [RISC-V] c impies zca, and conditionally zcf & zcd

 gcc/common/config/riscv/riscv-common.cc       | 26 ++++++++++++++++---
 gcc/config/riscv/riscv-subset.h               |  3 +++
 gcc/testsuite/gcc.target/riscv/arch-39.c      |  7 +++++
 gcc/testsuite/gcc.target/riscv/arch-40.c      |  7 +++++
 gcc/testsuite/gcc.target/riscv/attribute-15.c |  2 +-
 gcc/testsuite/gcc.target/riscv/attribute-18.c |  2 +-
 gcc/testsuite/gcc.target/riscv/pr110696.c     |  2 +-
 .../riscv/rvv/base/abi-callee-saved-1-zcmp.c  |  2 +-
 .../riscv/rvv/base/abi-callee-saved-2-zcmp.c  |  2 +-
 .../gcc.target/riscv/rvv/base/pr114352-1.c    |  4 +--
 .../gcc.target/riscv/rvv/base/pr114352-3.c    |  8 +++---
 11 files changed, 51 insertions(+), 14 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/riscv/arch-39.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/arch-40.c