Skip to content

Commit 4bfafea

Browse files
zhongjuzheIncarnation-p-lee
authored andcommitted
RISC-V: Tweak generic vector COST model
Notice current generic vector cost model make PR112387 failed to vectorize. Adapt it same as ARM SVE generic vector cost model which can fix it. Committed as it is obvious fix. PR target/112387 gcc/ChangeLog: * config/riscv/riscv.cc: Adapt generic cost model same ARM SVE. gcc/testsuite/ChangeLog: * gcc.dg/vect/costmodel/riscv/rvv/pr112387.c: Moved to... * gcc.dg/vect/costmodel/riscv/rvv/pr112387-1.c: ...here. * gcc.dg/vect/costmodel/riscv/rvv/pr112387-2.c: New test.
1 parent c7ef218 commit 4bfafea

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

gcc/config/riscv/riscv.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,13 @@ static const common_vector_cost generic_vls_vector_cost = {
355355
1, /* fp_stmt_cost */
356356
1, /* gather_load_cost */
357357
1, /* scatter_store_cost */
358-
1, /* vec_to_scalar_cost */
358+
2, /* vec_to_scalar_cost */
359359
1, /* scalar_to_vec_cost */
360-
1, /* permute_cost */
361-
3, /* align_load_cost */
362-
3, /* align_store_cost */
363-
3, /* unalign_load_cost */
364-
3, /* unalign_store_cost */
360+
2, /* permute_cost */
361+
1, /* align_load_cost */
362+
1, /* align_store_cost */
363+
1, /* unalign_load_cost */
364+
1, /* unalign_store_cost */
365365
};
366366

367367
/* Generic costs for VLA vector operations. */
@@ -371,13 +371,13 @@ static const scalable_vector_cost generic_vla_vector_cost = {
371371
1, /* fp_stmt_cost */
372372
1, /* gather_load_cost */
373373
1, /* scatter_store_cost */
374-
1, /* vec_to_scalar_cost */
374+
2, /* vec_to_scalar_cost */
375375
1, /* scalar_to_vec_cost */
376-
1, /* permute_cost */
377-
3, /* align_load_cost */
378-
3, /* align_store_cost */
379-
3, /* unalign_load_cost */
380-
3, /* unalign_store_cost */
376+
2, /* permute_cost */
377+
1, /* align_load_cost */
378+
1, /* align_store_cost */
379+
1, /* unalign_load_cost */
380+
1, /* unalign_store_cost */
381381
},
382382
};
383383

gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr112387.c renamed to gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr112387-1.c

File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-march=rv64gcv -mabi=lp64d -mtune=generic-ooo -O3 -ftree-vectorize -fdump-tree-vect-details" } */
3+
4+
#include <stdint-gcc.h>
5+
6+
void
7+
f2 (uint64_t *__restrict y, uint64_t *__restrict x,
8+
uint64_t *__restrict indices, uint64_t n)
9+
{
10+
for (int64_t i = 0; i < n; ++i)
11+
{
12+
y[i * 2] = x[indices[i * 2]] + 1;
13+
y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2;
14+
}
15+
}
16+
17+
/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect } } */
18+
/* { dg-final { scan-assembler-not "vlseg" } } */
19+
/* { dg-final { scan-assembler-not "vsseg" } } */

0 commit comments

Comments
 (0)