mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
RISC-V: Use biggest_mode as mode for constants.
In compute_nregs_for_mode we expect that the current variable's mode is at most as large as the biggest mode to be used for vectorization. This might not be true for constants as they don't actually have a mode. In that case, just use the biggest mode so max_number_of_live_regs returns 1. This fixes several test cases in the test suite. gcc/ChangeLog: PR target/116655 * config/riscv/riscv-vector-costs.cc (max_number_of_live_regs): Use biggest mode instead of constant's saved mode. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr116655.c: New test.
This commit is contained in:
parent
f9bac23884
commit
cc217a1ecb
@ -194,7 +194,7 @@ compute_local_program_points (
|
|||||||
/* Collect the stmts that is vectorized and mark their program point. */
|
/* Collect the stmts that is vectorized and mark their program point. */
|
||||||
for (i = 0; i < nbbs; i++)
|
for (i = 0; i < nbbs; i++)
|
||||||
{
|
{
|
||||||
int point = 1;
|
unsigned int point = 1;
|
||||||
basic_block bb = bbs[i];
|
basic_block bb = bbs[i];
|
||||||
vec<stmt_point> program_points = vNULL;
|
vec<stmt_point> program_points = vNULL;
|
||||||
if (dump_enabled_p ())
|
if (dump_enabled_p ())
|
||||||
@ -489,9 +489,15 @@ max_number_of_live_regs (loop_vec_info loop_vinfo, const basic_block bb,
|
|||||||
pair live_range = (*iter).second;
|
pair live_range = (*iter).second;
|
||||||
for (i = live_range.first + 1; i <= live_range.second; i++)
|
for (i = live_range.first + 1; i <= live_range.second; i++)
|
||||||
{
|
{
|
||||||
machine_mode mode = TREE_CODE (TREE_TYPE (var)) == BOOLEAN_TYPE
|
machine_mode mode;
|
||||||
? BImode
|
if (TREE_CODE (TREE_TYPE (var)) == BOOLEAN_TYPE)
|
||||||
: TYPE_MODE (TREE_TYPE (var));
|
mode = BImode;
|
||||||
|
/* Constants do not have a mode, just use the biggest so
|
||||||
|
compute_nregs will return 1. */
|
||||||
|
else if (TREE_CODE (var) == INTEGER_CST)
|
||||||
|
mode = biggest_mode;
|
||||||
|
else
|
||||||
|
mode = TYPE_MODE (TREE_TYPE (var));
|
||||||
unsigned int nregs
|
unsigned int nregs
|
||||||
= compute_nregs_for_mode (loop_vinfo, mode, biggest_mode, lmul);
|
= compute_nregs_for_mode (loop_vinfo, mode, biggest_mode, lmul);
|
||||||
live_vars_vec[i] += nregs;
|
live_vars_vec[i] += nregs;
|
||||||
|
11
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr116655.c
Normal file
11
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr116655.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O3 -march=rv64imv -mabi=lp64d -mrvv-max-lmul=dynamic" } */
|
||||||
|
|
||||||
|
short a[5];
|
||||||
|
int b() {
|
||||||
|
int c = 0;
|
||||||
|
for (; c <= 4; c++)
|
||||||
|
if (a[c])
|
||||||
|
break;
|
||||||
|
return c;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user