[PATCH] RISC-V: Fix PR109399 VSETVL PASS bug

PR 109399

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc
	(pass_vsetvl::compute_local_backward_infos): Update user vsetvl in local
	demand fusion.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/pr109399.c: New test.
This commit is contained in:
Juzhe-Zhong
2023-04-04 19:20:47 -06:00
committed by Jeff Law
parent 4f81edad41
commit fdc5abbdcf
2 changed files with 21 additions and 1 deletions
+7 -1
View File
@@ -2683,7 +2683,13 @@ pass_vsetvl::compute_local_backward_infos (const bb_info *bb)
if (!(propagate_avl_across_demands_p (change, info)
&& !reg_available_p (insn, change))
&& change.compatible_p (info))
info = change.merge (info);
{
info = change.merge (info);
/* Fix PR109399, we should update user vsetvl instruction
if there is a change in demand fusion. */
if (vsetvl_insn_p (insn->rtl ()))
change_vsetvl_insn (insn, info);
}
}
change = info;
}
@@ -0,0 +1,14 @@
/* { dg-do compile } */
/* { dg-options "-march=rv32gcv -mabi=ilp32 -fno-tree-vectorize -fno-schedule-insns -fno-schedule-insns2" } */
#include "riscv_vector.h"
void foo(void *in1, void *in2, void *in3, void *out, size_t n) {
size_t vl = __riscv_vsetvlmax_e32m1();
vint32m1_t a = __riscv_vle32_v_i32m1(in1, vl);
vint32m1_t b = __riscv_vle32_v_i32m1_tu(a, in2, vl);
vint32m1_t c = __riscv_vle32_v_i32m1_tu(b, in3, vl);
__riscv_vse32_v_i32m1(out, c, vl);
}
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e32,\s*m1,\s*tu,\s*m[au]} 1 { target { no-opts "-O0" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */