* [PATCH v1|GCC-13] RISC-V: Bugfix for riscv-vsetvl pass.
@ 2023-07-16 2:16 pan2.li
2023-07-18 13:57 ` Jeff Law
0 siblings, 1 reply; 3+ messages in thread
From: pan2.li @ 2023-07-16 2:16 UTC (permalink / raw)
To: gcc-patches; +Cc: juzhe.zhong, pan2.li, kito.cheng
From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
This patch comes from part of below change, which locate one bug of rvv
vsetvel pass when auto-vectorization.
https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624523.html
Unforunately, It is not easy to reproduce this bug by intrinsic APIs
but it is worth to backport to GCC 13.
Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (gen_vsetvl_pat): Add vl parameter.
(change_vsetvl_insn): Ditto.
(change_insn): Add validate change as well as assert.
(pass_vsetvl::backward_demand_fusion): Allow forward.
---
gcc/config/riscv/riscv-vsetvl.cc | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 3355ca4e3fb..fbd26988106 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -633,7 +633,8 @@ gen_vsetvl_pat (enum vsetvl_type insn_type, const vl_vtype_info &info, rtx vl)
}
static rtx
-gen_vsetvl_pat (rtx_insn *rinsn, const vector_insn_info &info)
+gen_vsetvl_pat (rtx_insn *rinsn, const vector_insn_info &info,
+ rtx vl = NULL_RTX)
{
rtx new_pat;
vl_vtype_info new_info = info;
@@ -644,7 +645,7 @@ gen_vsetvl_pat (rtx_insn *rinsn, const vector_insn_info &info)
if (vsetvl_insn_p (rinsn) || vlmax_avl_p (info.get_avl ()))
{
rtx dest = get_vl (rinsn);
- new_pat = gen_vsetvl_pat (VSETVL_NORMAL, new_info, dest);
+ new_pat = gen_vsetvl_pat (VSETVL_NORMAL, new_info, vl ? vl : dest);
}
else if (INSN_CODE (rinsn) == CODE_FOR_vsetvl_vtype_change_only)
new_pat = gen_vsetvl_pat (VSETVL_VTYPE_CHANGE_ONLY, new_info, NULL_RTX);
@@ -926,7 +927,8 @@ change_insn (rtx_insn *rinsn, rtx new_pat)
print_rtl_single (dump_file, PATTERN (rinsn));
}
- validate_change (rinsn, &PATTERN (rinsn), new_pat, false);
+ bool change_p = validate_change (rinsn, &PATTERN (rinsn), new_pat, false);
+ gcc_assert (change_p);
if (dump_file)
{
@@ -1039,7 +1041,8 @@ change_insn (function_info *ssa, insn_change change, insn_info *insn,
}
static void
-change_vsetvl_insn (const insn_info *insn, const vector_insn_info &info)
+change_vsetvl_insn (const insn_info *insn, const vector_insn_info &info,
+ rtx vl = NULL_RTX)
{
rtx_insn *rinsn;
if (vector_config_insn_p (insn->rtl ()))
@@ -1053,7 +1056,7 @@ change_vsetvl_insn (const insn_info *insn, const vector_insn_info &info)
rinsn = PREV_INSN (insn->rtl ());
gcc_assert (vector_config_insn_p (rinsn));
}
- rtx new_pat = gen_vsetvl_pat (rinsn, info);
+ rtx new_pat = gen_vsetvl_pat (rinsn, info, vl);
change_insn (rinsn, new_pat);
}
@@ -3331,7 +3334,21 @@ pass_vsetvl::backward_demand_fusion (void)
new_info))
continue;
- change_vsetvl_insn (new_info.get_insn (), new_info);
+ rtx vl = NULL_RTX;
+ /* Backward VLMAX VL:
+ bb 3:
+ vsetivli zero, 1 ... -> vsetvli t1, zero
+ vmv.s.x
+ bb 5:
+ vsetvli t1, zero ... -> to be elided.
+ vlse16.v
+
+ We should forward "t1". */
+ if (!block_info.reaching_out.has_avl_reg ()
+ && vlmax_avl_p (new_info.get_avl ()))
+ vl = get_vl (prop.get_insn ()->rtl ());
+ change_vsetvl_insn (new_info.get_insn (), new_info, vl);
+
if (block_info.local_dem == block_info.reaching_out)
block_info.local_dem = new_info;
block_info.reaching_out = new_info;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1|GCC-13] RISC-V: Bugfix for riscv-vsetvl pass.
2023-07-16 2:16 [PATCH v1|GCC-13] RISC-V: Bugfix for riscv-vsetvl pass pan2.li
@ 2023-07-18 13:57 ` Jeff Law
2023-07-18 14:06 ` Li, Pan2
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2023-07-18 13:57 UTC (permalink / raw)
To: pan2.li, gcc-patches; +Cc: juzhe.zhong, kito.cheng
On 7/15/23 20:16, Pan Li via Gcc-patches wrote:
> From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> This patch comes from part of below change, which locate one bug of rvv
> vsetvel pass when auto-vectorization.
>
> https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624523.html
>
> Unforunately, It is not easy to reproduce this bug by intrinsic APIs
> but it is worth to backport to GCC 13.
>
> Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> gcc/ChangeLog:
>
> * config/riscv/riscv-vsetvl.cc (gen_vsetvl_pat): Add vl parameter.
> (change_vsetvl_insn): Ditto.
> (change_insn): Add validate change as well as assert.
> (pass_vsetvl::backward_demand_fusion): Allow forward.
OK for gcc-13.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v1|GCC-13] RISC-V: Bugfix for riscv-vsetvl pass.
2023-07-18 13:57 ` Jeff Law
@ 2023-07-18 14:06 ` Li, Pan2
0 siblings, 0 replies; 3+ messages in thread
From: Li, Pan2 @ 2023-07-18 14:06 UTC (permalink / raw)
To: Jeff Law, gcc-patches; +Cc: juzhe.zhong, kito.cheng
Committed to GCC 13, thanks Jeff.
Pan
-----Original Message-----
From: Jeff Law <jeffreyalaw@gmail.com>
Sent: Tuesday, July 18, 2023 9:57 PM
To: Li, Pan2 <pan2.li@intel.com>; gcc-patches@gcc.gnu.org
Cc: juzhe.zhong@rivai.ai; kito.cheng@gmail.com
Subject: Re: [PATCH v1|GCC-13] RISC-V: Bugfix for riscv-vsetvl pass.
On 7/15/23 20:16, Pan Li via Gcc-patches wrote:
> From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> This patch comes from part of below change, which locate one bug of rvv
> vsetvel pass when auto-vectorization.
>
> https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624523.html
>
> Unforunately, It is not easy to reproduce this bug by intrinsic APIs
> but it is worth to backport to GCC 13.
>
> Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> gcc/ChangeLog:
>
> * config/riscv/riscv-vsetvl.cc (gen_vsetvl_pat): Add vl parameter.
> (change_vsetvl_insn): Ditto.
> (change_insn): Add validate change as well as assert.
> (pass_vsetvl::backward_demand_fusion): Allow forward.
OK for gcc-13.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-18 14:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-16 2:16 [PATCH v1|GCC-13] RISC-V: Bugfix for riscv-vsetvl pass pan2.li
2023-07-18 13:57 ` Jeff Law
2023-07-18 14:06 ` Li, Pan2
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).