]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Fix large memory usage of VSETVL PASS [PR113495]
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Tue, 23 Jan 2024 10:12:49 +0000 (18:12 +0800)
committerPan Li <pan2.li@intel.com>
Wed, 24 Jan 2024 00:29:42 +0000 (08:29 +0800)
commit3132d2d36b4705bb762e61b1c8ca4da7c78a8321
tree8692c2b3d6cffb6b66216ee24bb2b1d62a3c637f
parent3128786c7ea8fa0061f5bf9645f2ecaaecc2b031
RISC-V: Fix large memory usage of VSETVL PASS [PR113495]

SPEC 2017 wrf benchmark expose unreasonble memory usage of VSETVL PASS
that is, VSETVL PASS consume over 33 GB memory which make use impossible
to compile SPEC 2017 wrf in a laptop.

The root cause is wasting-memory variables:

unsigned num_exprs = num_bbs * num_regs;
sbitmap *avl_def_loc = sbitmap_vector_alloc (num_bbs, num_exprs);
sbitmap *m_kill = sbitmap_vector_alloc (num_bbs, num_exprs);
m_avl_def_in = sbitmap_vector_alloc (num_bbs, num_exprs);
m_avl_def_out = sbitmap_vector_alloc (num_bbs, num_exprs);

I find that compute_avl_def_data can be achieved by RTL_SSA framework.
Replace the code implementation base on RTL_SSA framework.

After this patch, the memory-hog issue is fixed.

simple vsetvl memory usage (valgrind --tool=massif --pages-as-heap=yes --massif-out-file=massif.out)
is 1.673 GB.

lazy vsetvl memory usage (valgrind --tool=massif --pages-as-heap=yes --massif-out-file=massif.out)
is 2.441 GB.

Tested on both RV32 and RV64, no regression.

gcc/ChangeLog:

PR target/113495
* config/riscv/riscv-vsetvl.cc (get_expr_id): Remove.
(get_regno): Ditto.
(get_bb_index): Ditto.
(pre_vsetvl::compute_avl_def_data): Ditto.
(pre_vsetvl::earliest_fuse_vsetvl_info): Fix large memory usage.
(pre_vsetvl::pre_global_vsetvl_info): Ditto.

gcc/testsuite/ChangeLog:

PR target/113495
* gcc.target/riscv/rvv/vsetvl/avl_single-107.c: Adapt test.
gcc/config/riscv/riscv-vsetvl.cc
gcc/testsuite/gcc.target/riscv/rvv/vsetvl/avl_single-107.c