This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/59446] New: loop2_doloop creates constant comparison and dead jump
- From: "olegendo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Dec 2013 11:19:43 +0000
- Subject: [Bug rtl-optimization/59446] New: loop2_doloop creates constant comparison and dead jump
- Auto-submitted: auto-generated
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.