public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/54369] New: Delayed-branch pass in reorg.c removes too many instructions
@ 2012-08-24 18:17 chaoyingfu at gcc dot gnu.org
  2012-08-29 22:43 ` [Bug rtl-optimization/54369] " ebotcazou at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: chaoyingfu at gcc dot gnu.org @ 2012-08-24 18:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54369

             Bug #: 54369
           Summary: Delayed-branch pass in reorg.c removes too many
                    instructions
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: chaoyingfu@gcc.gnu.org


Created attachment 28079
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28079
A simple test for an issue in reorg.c

Please check this example when using GCC 4.6 for mips-linux-gnu.
(I think the issue is in GCC 4.7 and later as well.  But due to the basic block
ordering, I cannot reproduce this issue.)
Ex:
# /gcc46branch/build-mips/gcc/cc1plus -quiet Bug.i -o Bug.s -mips32r2 -O2
# cat Bug.s
_Z3bugP9ValueRTRK:
        .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, gp= 0
        .mask   0x00000000,0
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        lw      $2,0($4) <---------
        lw      $2,0($2) <--------- (NO RETURN IN THIS FUNCTION.)
        .set    macro
        .set    reorder
        .end    _Z3bugP9ValueRTRK
        .cfi_endproc
$LFE13:
        .size   _Z3bugP9ValueRTRK, .-_Z3bugP9ValueRTRK
        .ident  "GCC: (GNU) 4.6.4 20120823 (prerelease) [gcc-4_6-branch
revision
 190613]"

  The delayed-branch pass in reorg.c is too aggressive, such that a return
instruction and others are removed.  From debugging code in reorg.c:
delete_jump() -> delete_computation() -> delete_related_insn(), I think we
should not use delete_related_insn() that removes branches and all the
following instructions.  A simple fix may be just using delete_insn() in
delete_computation().
Ex: # svn diff reorg.c
Index: reorg.c
===================================================================
--- reorg.c     (revision 190636)
+++ reorg.c     (working copy)
@@ -3298,7 +3298,7 @@
       delete_prior_computation (note, insn);
     }

-  delete_related_insns (insn);
+  delete_insn (insn);
 }

 /* If all INSN does is set the pc, delete it,

Ex: (Bug.s after this fix.)
# cat Bug.s
_Z3bugP9ValueRTRK:
        .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, gp= 0
        .mask   0x00000000,0
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        lw      $2,0($4)
        lw      $2,0($2)
$L4:
        j       $31      <------------- OK
        srl     $2,$2,8  <------------- OK

        .set    macro
        .set    reorder
        .end    _Z3bugP9ValueRTRK
        .cfi_endproc
$LFE13:
        .size   _Z3bugP9ValueRTRK, .-_Z3bugP9ValueRTRK
        .ident  "GCC: (GNU) 4.6.4 20120823 (prerelease) [gcc-4_6-branch
revision
 190613]"

Thanks!


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-02-16 10:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-24 18:17 [Bug rtl-optimization/54369] New: Delayed-branch pass in reorg.c removes too many instructions chaoyingfu at gcc dot gnu.org
2012-08-29 22:43 ` [Bug rtl-optimization/54369] " ebotcazou at gcc dot gnu.org
2012-08-31  0:31 ` sje at gcc dot gnu.org
2012-08-31  0:39 ` chaoyingfu at gcc dot gnu.org
2012-08-31 14:21 ` ebotcazou at gcc dot gnu.org
2012-08-31 18:17 ` sje at gcc dot gnu.org
2012-08-31 18:56 ` ebotcazou at gcc dot gnu.org
2012-09-01  8:17 ` rdsandiford at googlemail dot com
2012-09-01  9:22 ` ebotcazou at gcc dot gnu.org
2012-09-01  9:42 ` rdsandiford at googlemail dot com
2012-09-01 15:13 ` [Bug rtl-optimization/54369] delayed-branch pass " ebotcazou at gcc dot gnu.org
2012-09-02 10:37 ` ebotcazou at gcc dot gnu.org
2012-09-02 10:38 ` ebotcazou at gcc dot gnu.org
2012-09-02 10:39 ` ebotcazou at gcc dot gnu.org
2012-09-02 10:39 ` ebotcazou at gcc dot gnu.org
2012-09-02 10:39 ` ebotcazou at gcc dot gnu.org
2012-09-02 10:48 ` ebotcazou at gcc dot gnu.org
2014-02-16 10:00 ` jackie.rosen at hushmail dot com

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).