]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Remove redundant vec_duplicate pattern
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Mon, 18 Sep 2023 12:35:08 +0000 (20:35 +0800)
committerLehua Ding <lehua.ding@rivai.ai>
Mon, 18 Sep 2023 12:58:31 +0000 (20:58 +0800)
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.

gcc/config/riscv/riscv-selftests.cc
gcc/config/riscv/vector.md
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111313.c

index b16b5c1528670d9ea3dc396fe0d09d18ef63c1c8..cdc863ee4f7659c1356c37c32d82a93da545b056 100644 (file)
@@ -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))));   \
index 39b550c1bffe0c1c2598ffeaaa5bca575ccda3fc..6d3c43e05ee2937f0da0d307ba3a558d95158da5 100644 (file)
 ;; 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"
index 1da1b8ce6fb5b63bb2f708ebec0d4816efb74e45..1e01cfefd477f6d8ae19b4c9edc2c2804fcb2211 100644 (file)
@@ -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 } } */