* [PATCH] RISC-V: Fix PR109535
@ 2023-04-18 2:03 juzhe.zhong
2023-04-18 19:00 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: juzhe.zhong @ 2023-04-18 2:03 UTC (permalink / raw)
To: gcc-patches; +Cc: kito.cheng, palmer, Ju-Zhe Zhong
From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (count_regno_occurrences): New function.
(pass_vsetvl::cleanup_insns): Fix bug.
---
gcc/config/riscv/riscv-vsetvl.cc | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 1b66e3b9eeb..43e2cf08377 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -1592,6 +1592,19 @@ backward_propagate_worthwhile_p (const basic_block cfg_bb,
return true;
}
+/* Count the number of REGNO in RINSN. */
+int
+count_regno_occurrences (rtx_insn *rinsn, unsigned int regno)
+{
+ int count = 0;
+ extract_insn (rinsn);
+ for (int i = 0; i < recog_data.n_operands; i++)
+ if (REG_P (recog_data.operand[i])
+ && REGNO (recog_data.operand[i]) == regno)
+ count++;
+ return count;
+}
+
avl_info::avl_info (const avl_info &other)
{
m_value = other.get_value ();
@@ -3924,7 +3937,7 @@ pass_vsetvl::cleanup_insns (void) const
if (!has_vl_op (rinsn) || !REG_P (get_vl (rinsn)))
continue;
rtx avl = get_vl (rinsn);
- if (count_occurrences (PATTERN (rinsn), avl, 0) == 1)
+ if (count_regno_occurrences (rinsn, REGNO (avl)) == 1)
{
/* Get the list of uses for the new instruction. */
auto attempt = crtl->ssa->new_change_attempt ();
--
2.36.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RISC-V: Fix PR109535
2023-04-18 2:03 [PATCH] RISC-V: Fix PR109535 juzhe.zhong
@ 2023-04-18 19:00 ` Jeff Law
2023-04-18 19:03 ` Kito Cheng
2023-04-18 22:53 ` juzhe.zhong
0 siblings, 2 replies; 4+ messages in thread
From: Jeff Law @ 2023-04-18 19:00 UTC (permalink / raw)
To: juzhe.zhong, gcc-patches; +Cc: kito.cheng, palmer
On 4/17/23 20:03, juzhe.zhong@rivai.ai wrote:
> From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> gcc/ChangeLog:
>
> * config/riscv/riscv-vsetvl.cc (count_regno_occurrences): New function.
> (pass_vsetvl::cleanup_insns): Fix bug.
ChangeLog should reference the bug number, like this:
PR target/109535
>
> ---
> gcc/config/riscv/riscv-vsetvl.cc | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
> index 1b66e3b9eeb..43e2cf08377 100644
> --- a/gcc/config/riscv/riscv-vsetvl.cc
> +++ b/gcc/config/riscv/riscv-vsetvl.cc
> @@ -1592,6 +1592,19 @@ backward_propagate_worthwhile_p (const basic_block cfg_bb,
> return true;
> }
>
> +/* Count the number of REGNO in RINSN. */
> +int
> +count_regno_occurrences (rtx_insn *rinsn, unsigned int regno)
Seems like this ought to be static. Though it's not clear why
count_occurrences didn't do what you needed. Can you explain why
count_occurrences was insufficient for your needs?
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RISC-V: Fix PR109535
2023-04-18 19:00 ` Jeff Law
@ 2023-04-18 19:03 ` Kito Cheng
2023-04-18 22:53 ` juzhe.zhong
1 sibling, 0 replies; 4+ messages in thread
From: Kito Cheng @ 2023-04-18 19:03 UTC (permalink / raw)
To: Jeff Law; +Cc: juzhe.zhong, gcc-patches, palmer
Hi Jeff, Ju-Zhe:
Let you know that I am running creduce with this testcase for reduce
the size of testcsae, it's really too huge...
On Wed, Apr 19, 2023 at 3:00 AM Jeff Law via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
>
> On 4/17/23 20:03, juzhe.zhong@rivai.ai wrote:
> > From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
> >
> > gcc/ChangeLog:
> >
> > * config/riscv/riscv-vsetvl.cc (count_regno_occurrences): New function.
> > (pass_vsetvl::cleanup_insns): Fix bug.
> ChangeLog should reference the bug number, like this:
>
> PR target/109535
>
>
> >
> > ---
> > gcc/config/riscv/riscv-vsetvl.cc | 15 ++++++++++++++-
> > 1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
> > index 1b66e3b9eeb..43e2cf08377 100644
> > --- a/gcc/config/riscv/riscv-vsetvl.cc
> > +++ b/gcc/config/riscv/riscv-vsetvl.cc
> > @@ -1592,6 +1592,19 @@ backward_propagate_worthwhile_p (const basic_block cfg_bb,
> > return true;
> > }
> >
> > +/* Count the number of REGNO in RINSN. */
> > +int
> > +count_regno_occurrences (rtx_insn *rinsn, unsigned int regno)
> Seems like this ought to be static. Though it's not clear why
> count_occurrences didn't do what you needed. Can you explain why
> count_occurrences was insufficient for your needs?
>
>
>
>
> Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: [PATCH] RISC-V: Fix PR109535
2023-04-18 19:00 ` Jeff Law
2023-04-18 19:03 ` Kito Cheng
@ 2023-04-18 22:53 ` juzhe.zhong
1 sibling, 0 replies; 4+ messages in thread
From: juzhe.zhong @ 2023-04-18 22:53 UTC (permalink / raw)
To: Jeff Law, gcc-patches; +Cc: kito.cheng, palmer
[-- Attachment #1: Type: text/plain, Size: 2013 bytes --]
>> ChangeLog should reference the bug number, like this:
>> PR target/109535
>> Seems like this ought to be static. Though it's not clear why
>> count_occurrences didn't do what you needed. Can you explain why
>> count_occurrences was insufficient for your needs?
Address comment, I will resend a patch with referencing bug PR number and adding "static".
The reason why count_occurrences can not work since we want to count the regno occurrences
instead of rtx occurrences.
The bug issue reported by google/highway project:
(set(..........)
(reg:QI s0)
(reg:DI s0))
The "avl" operand rtx = (reg:DI s0)
count_occurrences return 1 however the actual regno occurrences should be 2.
Thanks
juzhe.zhong@rivai.ai
From: Jeff Law
Date: 2023-04-19 03:00
To: juzhe.zhong; gcc-patches
CC: kito.cheng; palmer
Subject: Re: [PATCH] RISC-V: Fix PR109535
On 4/17/23 20:03, juzhe.zhong@rivai.ai wrote:
> From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> gcc/ChangeLog:
>
> * config/riscv/riscv-vsetvl.cc (count_regno_occurrences): New function.
> (pass_vsetvl::cleanup_insns): Fix bug.
ChangeLog should reference the bug number, like this:
PR target/109535
>
> ---
> gcc/config/riscv/riscv-vsetvl.cc | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
> index 1b66e3b9eeb..43e2cf08377 100644
> --- a/gcc/config/riscv/riscv-vsetvl.cc
> +++ b/gcc/config/riscv/riscv-vsetvl.cc
> @@ -1592,6 +1592,19 @@ backward_propagate_worthwhile_p (const basic_block cfg_bb,
> return true;
> }
>
> +/* Count the number of REGNO in RINSN. */
> +int
> +count_regno_occurrences (rtx_insn *rinsn, unsigned int regno)
Seems like this ought to be static. Though it's not clear why
count_occurrences didn't do what you needed. Can you explain why
count_occurrences was insufficient for your needs?
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-18 22:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 2:03 [PATCH] RISC-V: Fix PR109535 juzhe.zhong
2023-04-18 19:00 ` Jeff Law
2023-04-18 19:03 ` Kito Cheng
2023-04-18 22:53 ` juzhe.zhong
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).