This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Init df for split pass since some target use REG_NOTE in split pattern


Hi Jeff:

Oop, patch in attachment, and I hit this bug in gcc.dg/torture/vshuf-v2di.c
with our nds32 internal branch.


Hi Richard:
I think we really need reg dead note for some optimization, and btw,
here is our split pattern:

(define_split
  [(set (match_operand:DI 0 "nds32_general_register_operand" "")
        (match_operand:DI 1 "nds32_general_register_operand" ""))]
  "find_regno_note (insn, REG_UNUSED, REGNO (operands[0])) != NULL
   || find_regno_note (insn, REG_UNUSED, REGNO (operands[0]) + 1) != NULL"
  [(set (match_dup 0) (match_dup 1))]
{
  rtx dead_note = find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
  HOST_WIDE_INT offset;
  if (dead_note == NULL_RTX)
    offset = 0;
  else
    offset = 4;
  operands[0] = simplify_gen_subreg (
                  SImode, operands[0],
                  DImode, offset);
  operands[1] = simplify_gen_subreg (
                  SImode, operands[1],
                  DImode, offset);
})



On Tue, Jul 26, 2016 at 3:48 AM, Jeff Law <law@redhat.com> wrote:
> On 07/25/2016 12:35 PM, Richard Biener wrote:
>>
>> On July 25, 2016 5:56:29 PM GMT+02:00, Jeff Law <law@redhat.com> wrote:
>>>
>>> On 07/25/2016 12:36 AM, Kito Cheng wrote:
>>>>
>>>> Hi all:
>>>>
>>>> Some target(for example i386, sh and h8300) use find_regno_note in
>>>> split pattern but df infrastructure seem not initialize at split
>>>
>>> pass,
>>>>
>>>> so it may got wrong note since it's out-of-date.
>>>>
>>>> ChangeLog
>>>> 2016-07-25  Kito Cheng <kito.cheng@gmail.com>
>>>>
>>>>         * gcc/recog.c (split_all_insns): Initialize df for split
>>>
>>> pass.
>>>>
>>>>         (split_all_insns_noflow): Likewise.
>>>>
>>> Patch was not included/attached to your message.  Please resend with
>>> the
>>> patch and hopefully a testcase which exhibits the problem.
>>
>>
>> And maybe back ends shouldn't look at notes in their splitters?
>
> It's certainly not ideal.    But I'm not sure what alternatives we have and
> it's bee supported for a very long time.
>
> For example on the H8, there is no shift-by-a-variable-amount.  Instead you
> have to emit it as a loop.  However, we don't expose the loop until late in
> the RTL pipeline (via a splitter).  When we split a variable shift into a
> loop, one of the things we want to know is whether or not the register
> holding the shift count dies or not.  If it does not die, we'll just use it
> rather than copying it elsewhere.
>
> Similarly we can generate a more efficient split for something like (ior
> (ashift (X) (const_int)) for certain integers when we know the input dies.
> Or for some (add (mult)) expressions.
>
> Jeff
>
>
From c70bf21e152f24aa21592275626840569bbcdd08 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito@andestech.com>
Date: Mon, 25 Jul 2016 14:05:57 +0800
Subject: [PATCH] Initialize df for split pass since some target use REG_NOTE
 in split pattern

---
 gcc/recog.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/gcc/recog.c b/gcc/recog.c
index 80d1779..991fbc1 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2939,6 +2939,12 @@ split_all_insns (void)
   bool changed;
   basic_block bb;
 
+  if (optimize > 0)
+    {
+      df_note_add_problem ();
+      df_analyze ();
+    }
+
   blocks = sbitmap_alloc (last_basic_block_for_fn (cfun));
   bitmap_clear (blocks);
   changed = false;
@@ -3000,6 +3006,8 @@ unsigned int
 split_all_insns_noflow (void)
 {
   rtx_insn *next, *insn;
+  df_note_add_problem ();
+  df_analyze ();
 
   for (insn = get_insns (); insn; insn = next)
     {
@@ -3873,7 +3881,7 @@ const pass_data pass_data_split_all_insns =
   0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
-  0, /* todo_flags_finish */
+  TODO_df_finish, /* todo_flags_finish */
 };
 
 class pass_split_all_insns : public rtl_opt_pass
@@ -3926,7 +3934,7 @@ const pass_data pass_data_split_after_reload =
   0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
-  0, /* todo_flags_finish */
+  TODO_df_finish, /* todo_flags_finish */
 };
 
 class pass_split_after_reload : public rtl_opt_pass
@@ -3964,7 +3972,7 @@ const pass_data pass_data_split_before_regstack =
   0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
-  0, /* todo_flags_finish */
+  TODO_df_finish, /* todo_flags_finish */
 };
 
 class pass_split_before_regstack : public rtl_opt_pass
@@ -4031,7 +4039,7 @@ const pass_data pass_data_split_before_sched2 =
   0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
-  0, /* todo_flags_finish */
+  TODO_df_finish, /* todo_flags_finish */
 };
 
 class pass_split_before_sched2 : public rtl_opt_pass
@@ -4078,7 +4086,7 @@ const pass_data pass_data_split_for_shorten_branches =
   0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
-  0, /* todo_flags_finish */
+  TODO_df_finish, /* todo_flags_finish */
 };
 
 class pass_split_for_shorten_branches : public rtl_opt_pass
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]