public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5507] RISC-V: fix vsetvli pass testsuite failure [PR/112447]
@ 2023-11-15 17:35 Vineet Gupta
0 siblings, 0 replies; only message in thread
From: Vineet Gupta @ 2023-11-15 17:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d1189ceefc1da1515e039c9cfd2f5a67b5820207
commit r14-5507-gd1189ceefc1da1515e039c9cfd2f5a67b5820207
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date: Tue Nov 14 19:23:19 2023 -0800
RISC-V: fix vsetvli pass testsuite failure [PR/112447]
Fixes: f0e28d8c1371 ("RISC-V: Fix failed hoist in LICM of vmv.v.x instruction")
Since above commit, we have following failure:
FAIL: gcc.c-torture/execute/memset-3.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test
FAIL: gcc.c-torture/execute/memset-3.c -O3 -g execution test
The issue was not the commit but rather it unravelled an issue in the
vsetvli pass.
Here's Juzhe's analysis:
We have 2 types of global vsetvls insertion.
One is earliest fusion of each end of the block.
The other is LCM suggested edge vsetvls.
So before this patch, insertion as follows:
| (insn 2817 2820 2818 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 8 [0x8])
| (const_int 7 [0x7])
| (const_int 1 [0x1]) repeated x2
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
| (insn 2818 2817 999 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 32 [0x20])
| (const_int 1 [0x1]) repeated x3
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
After this patch:
| (insn 2817 2820 2819 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 32 [0x20])
| (const_int 1 [0x1]) repeated x3
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
| (insn 2819 2817 999 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 8 [0x8])
| (const_int 7 [0x7])
| (const_int 1 [0x1]) repeated x2
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
The original insertion order is incorrect.
We should first insert earliest fusion since it is the vsetvls information
already there which was seen by later LCM. We just delay the insertion.
So it should be come before the LCM suggested insertion.
PR target/112447
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (pre_vsetvl::emit_vsetvl): Insert
local vsetvl info before LCM suggested one.
Tested-by: Patrick O'Neill <patrick@rivosinc.com> # pre-commit-CI #679
Co-developed-by: Vineet Gupta <vineetg@rivosinc.com>
Diff:
---
gcc/config/riscv/riscv-vsetvl.cc | 70 ++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 8466b5d019e..74367ec8d8e 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -3229,6 +3229,41 @@ pre_vsetvl::emit_vsetvl ()
remove_vsetvl_insn (item);
}
+ /* Insert vsetvl info that was not deleted after lift up. */
+ for (const bb_info *bb : crtl->ssa->bbs ())
+ {
+ const vsetvl_block_info &block_info = get_block_info (bb);
+ if (!block_info.has_info ())
+ continue;
+
+ const vsetvl_info &footer_info = block_info.get_exit_info ();
+
+ if (footer_info.delete_p ())
+ continue;
+
+ edge eg;
+ edge_iterator eg_iterator;
+ FOR_EACH_EDGE (eg, eg_iterator, bb->cfg_bb ()->succs)
+ {
+ gcc_assert (!(eg->flags & EDGE_ABNORMAL));
+ if (dump_file)
+ {
+ fprintf (
+ dump_file,
+ "\n Insert missed vsetvl info at edge(bb %u -> bb %u): ",
+ eg->src->index, eg->dest->index);
+ footer_info.dump (dump_file, " ");
+ }
+ start_sequence ();
+ insert_vsetvl_insn (EMIT_DIRECT, footer_info);
+ rtx_insn *rinsn = get_insns ();
+ end_sequence ();
+ default_rtl_profile ();
+ insert_insn_on_edge (rinsn, eg);
+ need_commit = true;
+ }
+ }
+
/* m_insert vsetvl as LCM suggest. */
for (int ed = 0; ed < NUM_EDGES (m_edges); ed++)
{
@@ -3267,41 +3302,6 @@ pre_vsetvl::emit_vsetvl ()
insert_insn_on_edge (rinsn, eg);
}
- /* Insert vsetvl info that was not deleted after lift up. */
- for (const bb_info *bb : crtl->ssa->bbs ())
- {
- const vsetvl_block_info &block_info = get_block_info (bb);
- if (!block_info.has_info ())
- continue;
-
- const vsetvl_info &footer_info = block_info.get_exit_info ();
-
- if (footer_info.delete_p ())
- continue;
-
- edge eg;
- edge_iterator eg_iterator;
- FOR_EACH_EDGE (eg, eg_iterator, bb->cfg_bb ()->succs)
- {
- gcc_assert (!(eg->flags & EDGE_ABNORMAL));
- if (dump_file)
- {
- fprintf (
- dump_file,
- "\n Insert missed vsetvl info at edge(bb %u -> bb %u): ",
- eg->src->index, eg->dest->index);
- footer_info.dump (dump_file, " ");
- }
- start_sequence ();
- insert_vsetvl_insn (EMIT_DIRECT, footer_info);
- rtx_insn *rinsn = get_insns ();
- end_sequence ();
- default_rtl_profile ();
- insert_insn_on_edge (rinsn, eg);
- need_commit = true;
- }
- }
-
if (need_commit)
commit_edge_insertions ();
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-15 17:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 17:35 [gcc r14-5507] RISC-V: fix vsetvli pass testsuite failure [PR/112447] Vineet Gupta
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).