]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Forbidden fuse vlmax vsetvl to DEMAND_NONZERO_AVL vsetvl
authorLehua Ding <lehua.ding@rivai.ai>
Thu, 17 Aug 2023 07:42:51 +0000 (15:42 +0800)
committerLehua Ding <lehua.ding@rivai.ai>
Fri, 18 Aug 2023 02:29:44 +0000 (10:29 +0800)
Hi,

This little patch fix the fail testcase
(gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c)
after apply this patch
(https://gcc.gnu.org/pipermail/gcc-patches/2023-August/627121.html).
The specific reason is that the vsetvl pass has bug and this patch
forbidden the fuse of this case. This patch needs to be committed
before that patch to work.

Best,
Lehua

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (pass_vsetvl::backward_demand_fusion):
Forbidden.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c:
Address failure due to uninitialized vtype register.

gcc/config/riscv/riscv-vsetvl.cc
gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c

index 79cbac010475c6c5d5ddf4fae6c6f7faaf45330b..2d8fa754ea090c3ee75a680f9ecedf7141619f9a 100644 (file)
@@ -3330,6 +3330,23 @@ pass_vsetvl::backward_demand_fusion (void)
          else if (block_info.reaching_out.dirty_p ())
            {
              /* DIRTY -> DIRTY or VALID -> DIRTY.  */
+
+             /* Forbidden this case fuse because it change the value of a5.
+                  bb 1: vsetvl zero, no_zero_avl
+                        ...
+                        use a5
+                        ...
+                  bb 2: vsetvl a5, zero
+                =>
+                  bb 1: vsetvl a5, zero
+                        ...
+                        use a5
+                        ...
+                  bb 2:
+             */
+             if (block_info.reaching_out.demand_p (DEMAND_NONZERO_AVL)
+                 && vlmax_avl_p (prop.get_avl ()))
+               continue;
              vector_insn_info new_info;
 
              if (block_info.reaching_out.compatible_p (prop))
index 7ffa93bf13f26b07d38c5f6a25b5706c4a59b1a0..7eeb22aade27e3db0a17986c7835f41984975514 100644 (file)
@@ -7,6 +7,12 @@
 int
 main (void)
 {
+  /* FIXME: The purpose of this assembly is to ensure that the vtype register is
+     initialized befor instructions such as vmv1r.v are executed. Otherwise you
+     will get illegal instruction errors when running with spike+pk. This is an
+     interim solution for reduce unnecessary failures and a unified solution
+     will come later. */
+  asm volatile("vsetivli x0, 0, e8, m1, ta, ma");
 #define RUN_LOOP(DATA_TYPE, BITS)                                              \
   DATA_TYPE dest_##DATA_TYPE##_##BITS[(BITS - 3) * (BITS + 13)];               \
   DATA_TYPE dest2_##DATA_TYPE##_##BITS[(BITS - 3) * (BITS + 13)];              \