public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/59446] New: loop2_doloop creates constant comparison and dead jump
Date: Tue, 10 Dec 2013 11:19:00 -0000	[thread overview]
Message-ID: <bug-59446-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 59446
           Summary: loop2_doloop creates constant comparison and dead jump
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
                CC: law at redhat dot com
            Target: sh*-*-*

After the commit that fixed PR 58640
http://gcc.gnu.org/viewcvs?rev=203463&root=gcc&view=rev

the SH specific test case gcc.target/sh/pr51244-18.c caught the following
sequence:

.L15:
    mov    #0,r1      // r1 = 0
    tst    r1,r1      // T = r1 == 0
    bf.s    .L7        // if (T == 0) goto .L7
    add    #-4,r9

The branch above never happens and is dead code.
Something causes the loop2_doloop RTL pass to create the following code, which
results in the above final code. 

(code_label 108 107 109 4 2 "" [0 uses])
(note 109 108 110 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
      .
      .
      .
(insn 177 176 185 4 (set (reg:SI 304)
        (plus:SI (reg:SI 305)
            (const_int 1 [0x1]))) -1
     (nil))

(note 185 177 180 16 [bb 16] NOTE_INSN_BASIC_BLOCK)
(insn 180 185 182 16 (set (reg:SI 306)
        (plus:SI (reg/v:SI 278 [ k ])
            (const_int -8 [0xfffffffffffffff8]))) -1
     (nil))
(insn 182 180 183 16 (set (reg:SI 307)
        (const_int -8 [0xfffffffffffffff8])) -1
     (nil))
(insn 183 182 184 16 (set (reg:SI 147 t)
        (ge:SI (reg:SI 306)
            (reg:SI 307))) -1
     (nil))
(jump_insn 184 183 181 16 (set (pc)
        (if_then_else (eq (reg:SI 147 t)
                (const_int 0 [0]))
            (label_ref 181)
            (pc))) -1
     (int_list:REG_BR_PROB 0 (nil))
 -> 181)


(code_label 181 184 178 14 10 "" [1 uses])
(note 178 181 186 14 [bb 14] NOTE_INSN_BASIC_BLOCK)
(insn 186 178 179 14 (set (reg:SI 304)
        (const_int 1 [0x1])) -1
     (nil))

(note 179 186 155 15 [bb 15] NOTE_INSN_BASIC_BLOCK)
      .
      .
      .

      .
      .
      .

(code_label 149 146 150 9 5 "" [1 uses])
(note 150 149 151 9 [bb 9] NOTE_INSN_BASIC_BLOCK)
(insn 151 150 152 9 (set (reg/v:SI 261 [ k ])
        (plus:SI (reg/v:SI 261 [ k ])
            (const_int -8 [0xfffffffffffffff8]))) pr51244-18.c:48 68
{*addsi3_compact}
     (nil))
(insn 152 151 175 9 (set (reg:SI 147 t)
        (ge:SI (reg/v:SI 261 [ k ])
            (const_int 0 [0]))) pr51244-18.c:49 20 {cmpgesi_t}
     (nil))
(jump_insn 175 152 174 9 (parallel [
            (set (pc)
                (if_then_else (ne:SI (reg:SI 304)
                        (const_int 1 [0x1]))
                    (label_ref 174)
                    (pc)))
            (set (reg:SI 304)
                (plus (reg:SI 304)
                    (const_int -1 [0xffffffffffffffff])))
            (clobber (reg:SI 147 t))
        ]) pr51244-18.c:49 -1
     (int_list:REG_BR_PROB 9700 (nil))
 -> 174)


jump_insn 175 is SH's decrement-and-test pattern that is used for loops.


             reply	other threads:[~2013-12-10 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10 11:19 olegendo at gcc dot gnu.org [this message]
2013-12-10 22:00 ` [Bug rtl-optimization/59446] " law at redhat dot com
2013-12-10 22:17 ` olegendo at gcc dot gnu.org
2013-12-11 22:15 ` law at gcc dot gnu.org
2013-12-11 22:16 ` law at redhat dot com
2013-12-11 22:42 ` olegendo at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-59446-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).