public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4099] RISC-V: Remove redundant vec_duplicate pattern
@ 2023-09-18 12:58 Lehua Ding
0 siblings, 0 replies; only message in thread
From: Lehua Ding @ 2023-09-18 12:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4260f4af4dde6dbf85c28da7e8aaf03985b3d171
commit r14-4099-g4260f4af4dde6dbf85c28da7e8aaf03985b3d171
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date: Mon Sep 18 20:35:08 2023 +0800
RISC-V: Remove redundant vec_duplicate pattern
Currently, VLS and VLA patterns are different.
VLA is define_expand
VLS is define_insn_and_split
It makes no sense that they are different pattern format.
Merge them into same pattern (define_insn_and_split).
It can also be helpful for the future vv -> vx fwprop optimization.
gcc/ChangeLog:
* config/riscv/riscv-selftests.cc (run_broadcast_selftests): Adapt selftests.
* config/riscv/vector.md (@vec_duplicate<mode>): Remove.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr111313.c: Adapt test.
Diff:
---
gcc/config/riscv/riscv-selftests.cc | 4 ++--
gcc/config/riscv/vector.md | 18 +++---------------
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111313.c | 4 ++--
3 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/gcc/config/riscv/riscv-selftests.cc b/gcc/config/riscv/riscv-selftests.cc
index b16b5c15286..cdc863ee4f7 100644
--- a/gcc/config/riscv/riscv-selftests.cc
+++ b/gcc/config/riscv/riscv-selftests.cc
@@ -343,7 +343,7 @@ run_broadcast_selftests (void)
rtx mem = gen_rtx_MEM (inner_mode, addr); \
expand_vector_broadcast (mode, mem); \
insn = get_last_insn (); \
- src = XEXP (SET_SRC (PATTERN (insn)), 1); \
+ src = SET_SRC (PATTERN (insn)); \
ASSERT_TRUE (MEM_P (XEXP (src, 0))); \
ASSERT_TRUE ( \
rtx_equal_p (src, gen_rtx_VEC_DUPLICATE (mode, XEXP (src, 0)))); \
@@ -353,7 +353,7 @@ run_broadcast_selftests (void)
rtx reg = gen_reg_rtx (inner_mode); \
expand_vector_broadcast (mode, reg); \
insn = get_last_insn (); \
- src = XEXP (SET_SRC (PATTERN (insn)), 1); \
+ src = SET_SRC (PATTERN (insn)); \
ASSERT_TRUE (REG_P (XEXP (src, 0))); \
ASSERT_TRUE ( \
rtx_equal_p (src, gen_rtx_VEC_DUPLICATE (mode, XEXP (src, 0)))); \
diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md
index 39b550c1bff..6d3c43e05ee 100644
--- a/gcc/config/riscv/vector.md
+++ b/gcc/config/riscv/vector.md
@@ -1371,22 +1371,10 @@
;; This pattern only handles duplicates of non-constant inputs.
;; Constant vectors go through the movm pattern instead.
;; So "direct_broadcast_operand" can only be mem or reg, no CONSTANT.
-(define_expand "@vec_duplicate<mode>"
- [(set (match_operand:V 0 "register_operand")
- (vec_duplicate:V
- (match_operand:<VEL> 1 "direct_broadcast_operand")))]
- "TARGET_VECTOR"
- {
- riscv_vector::emit_vlmax_insn (code_for_pred_broadcast (<MODE>mode),
- riscv_vector::UNARY_OP, operands);
- DONE;
- }
-)
-
(define_insn_and_split "@vec_duplicate<mode>"
- [(set (match_operand:VLS 0 "register_operand")
- (vec_duplicate:VLS
- (match_operand:<VEL> 1 "reg_or_int_operand")))]
+ [(set (match_operand:V_VLS 0 "register_operand")
+ (vec_duplicate:V_VLS
+ (match_operand:<VEL> 1 "direct_broadcast_operand")))]
"TARGET_VECTOR && can_create_pseudo_p ()"
"#"
"&& 1"
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111313.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111313.c
index 1da1b8ce6fb..1e01cfefd47 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111313.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111313.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-march=rv64gcv -mabi=lp64d --param=riscv-autovec-preference=scalable -O3" } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d --param=riscv-autovec-preference=scalable -O3 -fno-schedule-insns -fno-schedule-insns2" } */
#define K 32
short in[2*K][K];
@@ -17,4 +17,4 @@ foo ()
}
}
-/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e16,\s*mf2,\s*t[au],\s*m[au]} 3 } } */
+/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf2,\s*t[au],\s*m[au]\s+vmv\.v\.x} 1 } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-18 12:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18 12:58 [gcc r14-4099] RISC-V: Remove redundant vec_duplicate pattern Lehua Ding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).