Skip to content

Commit 6be1b9e

Browse files
author
Robin Dapp
committed
RISC-V: Include pattern stmts for dynamic LMUL computation [PR114516].
When scanning for program points, i.e. vector statements, we're missing pattern statements. In PR114516 this becomes obvious as we choose LMUL=8 assuming there are only three statements but the divmod pattern adds another three. Those push us beyond four registers so we need to switch to LMUL=4. This patch adds pattern statements to the program points which helps calculate a better register pressure estimate. PR target/114516 gcc/ChangeLog: * config/riscv/riscv-vector-costs.cc (compute_estimated_lmul): Add pattern statements to program points. gcc/testsuite/ChangeLog: * gcc.dg/vect/costmodel/riscv/rvv/pr114516.c: New test.
1 parent f3d4208 commit 6be1b9e

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

gcc/config/riscv/riscv-vector-costs.cc

+29
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,35 @@ compute_local_program_points (
217217
"program point %d: %G", info.point,
218218
gsi_stmt (si));
219219
}
220+
221+
/* If the statement is part of a pattern, also add the other
222+
pattern statements. */
223+
gimple_seq pattern_def_seq;
224+
if (STMT_VINFO_IN_PATTERN_P (stmt_info)
225+
&& (pattern_def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info)))
226+
{
227+
gimple_stmt_iterator si2;
228+
229+
for (si2 = gsi_start (pattern_def_seq);
230+
!gsi_end_p (si2);
231+
gsi_next (&si2))
232+
{
233+
stmt_vec_info pattern_def_stmt_info
234+
= vinfo->lookup_stmt (gsi_stmt (si2));
235+
if (STMT_VINFO_RELEVANT_P (pattern_def_stmt_info)
236+
|| STMT_VINFO_LIVE_P (pattern_def_stmt_info))
237+
{
238+
stmt_point info = {point, gsi_stmt (si2),
239+
pattern_def_stmt_info};
240+
program_points.safe_push (info);
241+
point++;
242+
if (dump_enabled_p ())
243+
dump_printf_loc (MSG_NOTE, vect_location,
244+
"program point %d: %G",
245+
info.point, gsi_stmt (si2));
246+
}
247+
}
248+
}
220249
}
221250
program_points_per_bb.put (bb, program_points);
222251
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-march=rv64gcv_zba_zbb -mabi=lp64d -mrvv-max-lmul=dynamic -O3 -fdump-tree-vect-details" } */
3+
4+
typedef float real_t;
5+
__attribute__((aligned(64))) real_t a[32000];
6+
real_t s315()
7+
{
8+
for (int i = 0; i < 32000; i++)
9+
a[i] = (i * 7) % 32000;
10+
real_t x, chksum;
11+
int index;
12+
for (int nl = 0; nl < 256; nl++) {
13+
x = a[0];
14+
index = 0;
15+
for (int i = 0; i < 32000; ++i) {
16+
if (a[i] > x) {
17+
x = a[i];
18+
index = i;
19+
}
20+
}
21+
chksum = x + (real_t) index;
22+
}
23+
return index + x + 1;
24+
}
25+
26+
/* { dg-final { scan-assembler {e32,m4} } } */
27+
/* { dg-final { scan-assembler-not {e32,m8} } } */
28+
/* { dg-final { scan-assembler-not {csrr} } } */
29+
/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */

0 commit comments

Comments
 (0)