This is the mail archive of the gcc-bugs@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]

DELETE_INSN() fails to delete BARRIER in some case



Oops, I'v missed the ML address.

Message-Id: <20020405.130110.106417405.machida@sm.sony.co.jp>
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Subject: DELETE_INSN() fails to delete BARRIER in some case
From: Hiroyuki Machida <machida@sm.sony.co.jp>
To: gcc-patches@gcc.gnu.org, gcc-bugs@sm.sony.co.j
Cc: "Atsushi Nemoto" <nemoto@toshiba-tops.co.jp>,
   "Maciej	W. Rozycki" <macro@ds2.pg.gda.pl>
Date: Fri, 05 Apr 2002 13:01:10 +0900 (JST)
X-Mailer: Mew version 2.1.51 on Emacs 20.7 / Mule 4.0 (HANANOEN)
X-Mew: tab/spc characters on Subject: are simplified.


Hello, all

Atsushi Nemoto <nemoto@toshiba-tops.co.jp> reported the optimizer
bug of gcc-2.95.3 for mips-linux in 
    http://marc.theaimsgroup.com/?l=linux-mips&m=101788946915832&w=2

I tracked down the bug and found DELETE_INSN() failed to delete
BARRIER in some case. I think this problem potentially occures in
any target, even in gcc-3.x.

I attached a patch, bootstraped on gcc-2.95.3 for mipsel-linux.
Please apply it to gcc-3.0, gcc-3.1 branch and HEAD.

Thanks.

---

DETAILED DESCRIPTIONS

I got following RTLs with  the reported test code on 2nd jump
optimization.

Optimizer would try to delete both "JUMP_INSN 58" and it's barrier 
"BARRIER 61". But DELETE_INSN() failed to delete "BARRIER 61".
Because threre is NOTE_ININ_BASIC_BLOCK between JUMP_INSN and
it's BARRIER.
Then, unexpected code deletion was caued by the remained BARRIER.

	:
	:
(note 6 4 78 "" NOTE_INSN_DELETED)
(note 78 6 93 [bb 0] NOTE_INSN_BASIC_BLOCK)
(note 93 78 45 "" NOTE_INSN_PROLOGUE_END)
(insn 45 93 46 (set (reg:SI 6 a2)
        (leu:SI (reg:SI 6 a2)
            (const_int 4 [0x4]))) 414 {sleu_si_const} (nil)
    (nil))
(jump_insn 46 45 48 (set (pc)
        (if_then_else (ne:SI (reg:SI 6 a2)
                (const_int 0 [0x0]))
            (pc)
            (label_ref 36))) 342 {branch_zero} (insn_list/j/c 45
        (insn_list/j/c 45 (nil)))
    (expr_list:REG_DEAD (reg:SI 6 a2)
        (nil)))
(note 48 46 52 "" NOTE_INSN_DELETED)
(note 52 48 54 "" NOTE_INSN_DELETED)
(note 54 52 56 "" NOTE_INSN_DELETED)
(note 56 54 79 "" NOTE_INSN_DELETED)
(note 79 56 58 [bb 1] NOTE_INSN_BASIC_BLOCK)
(jump_insn 58 79 92 (set (pc)
        (label_ref 62)) 432 {jump} (nil)
    (nil))
(note 92 58 61 [bb 2] NOTE_INSN_BASIC_BLOCK)
(barrier 61 92 14)
(note 14 61 15 ("O2.c") 7)
(note 15 14 36 "" NOTE_INSN_DELETED)
(code_label 36 15 80 9 "" [num uses: 2])
	:
	:
---
Index: jump.c
===================================================================


retrieving revision 1.1.3.1
diff -p -c -r1.1.3.1 jump.c
*** jump.c	7 Dec 2001 13:32:27 -0000	1.1.3.1
--- jump.c	5 Apr 2002 03:19:25 -0000
*************** delete_insn (insn)
*** 3957,3962 ****
--- 3957,3963 ----
    register rtx prev = PREV_INSN (insn);
    register int was_code_label = (GET_CODE (insn) == CODE_LABEL);
    register int dont_really_delete = 0;
+   rtx next_nonote = next_nonnote_insn(insn);
  
    while (next && INSN_DELETED_P (next))
      next = NEXT_INSN (next);
*************** delete_insn (insn)
*** 3987,3998 ****
      delete_from_jump_chain (insn);
  
    /* If instruction is followed by a barrier,
!      delete the barrier too.  */
! 
!   if (next != 0 && GET_CODE (next) == BARRIER)
      {
!       INSN_DELETED_P (next) = 1;
!       next = NEXT_INSN (next);
      }
  
    /* Patch out INSN (and the barrier if any) */
--- 3988,4000 ----
      delete_from_jump_chain (insn);
  
    /* If instruction is followed by a barrier,
!      delete the barrier too. In some case, there are 
!      NOTEs like NOTE_INSN_BASIC_BLOCK but NOTE_INSN_DELETED,
!      between JUMP_INSN and BARRIER */
!   if (next_nonote != 0 && GET_CODE (next_nonote) == BARRIER)
      {
!       INSN_DELETED_P (next_nonote) = 1;
!       next = NEXT_INSN (next_nonote);
      }
  
    /* Patch out INSN (and the barrier if any) */
---
Hiroyuki Machida
Sony Corp.


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