public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/56605] New: Redundant branch introduced during loop2 phases
@ 2013-03-12 18:57 wschmidt at gcc dot gnu.org
  2013-03-12 19:20 ` [Bug rtl-optimization/56605] " steven at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2013-03-12 18:57 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56605
           Summary: Redundant branch introduced during loop2 phases
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: wschmidt@gcc.gnu.org
                CC: bergner@vnet.ibm.com
              Host: powerpc64-unknown-linux-gnu
            Target: powerpc64-unknown-linux-gnu
             Build: powerpc64-unknown-linux-gnu


I've recently noticed that GCC commonly generates redundant branches prior to
vectorized loops, such as:

   cmpwi 7,12,0
    ...
   beq- 7,.L22
   beq- 7,.L22
   .p2align 4,,15
.L8:
    ... loop body ...

The branches first appear in the 186r.loop2_doloop debug dump:

(note 260 254 258 23 [bb 23] NOTE_INSN_BASIC_BLOCK)
(insn 258 260 259 23 (set (reg:CC 330)
        (compare:CC (subreg:SI (reg:DI 153 [ bnd.10+-4 ]) 4)
            (const_int 0 [0]))) -1
     (nil))
(jump_insn 259 258 263 23 (set (pc)
        (if_then_else (eq (reg:CC 330)
                (const_int 0 [0]))
            (label_ref 257)
            (pc))) -1
     (expr_list:REG_BR_PROB (const_int 0 [0])
        (nil))
 -> 257)
(note 263 259 261 24 [bb 24] NOTE_INSN_BASIC_BLOCK)
(insn 261 263 262 24 (set (reg:CC 331)
        (compare:CC (subreg:SI (reg:DI 153 [ bnd.10+-4 ]) 4)
            (const_int 0 [0]))) -1
     (nil))
(jump_insn 262 261 257 24 (set (pc)
        (if_then_else (eq (reg:CC 331)
                (const_int 0 [0]))
            (label_ref 257)
            (pc))) -1
     (expr_list:REG_BR_PROB (const_int 0 [0])
        (nil))
 -> 257)

Subsequently GCC removes the redundant compare, but does not remove the
redundant branch.

Simple test case to reproduce:

#define N 4000
void foo(short* __restrict sb, int* __restrict ia) {
  int i;
  for (i = 0; i < N; i++)
    ia[i] = (int) sb[i];
}

$GCC_INSTALL/bin/gcc -S -O3 -mvsx example.c

(-mvsx is necessary to vectorize the loop.  It may also be necessary to add
-mcpu=power7.)


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

end of thread, other threads:[~2013-04-23 19:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-12 18:57 [Bug rtl-optimization/56605] New: Redundant branch introduced during loop2 phases wschmidt at gcc dot gnu.org
2013-03-12 19:20 ` [Bug rtl-optimization/56605] " steven at gcc dot gnu.org
2013-03-12 19:54 ` steven at gcc dot gnu.org
2013-03-12 23:00 ` steven at gcc dot gnu.org
2013-03-12 23:15 ` steven at gcc dot gnu.org
2013-04-15 18:32 ` wschmidt at gcc dot gnu.org
2013-04-23 19:49 ` wschmidt at gcc dot gnu.org

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