This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
new -O0 jump optimization causes SH regressions
- To: rth at cygnus dot com
- Subject: new -O0 jump optimization causes SH regressions
- From: Joern Rennecke <amylaar at cygnus dot co dot uk>
- Date: Thu, 20 Jan 2000 20:38:27 +0000 (GMT)
- CC: gcc at gcc dot gnu dot org
This change:
* jump.c (jump_optimize_1): Do simple jump optimizations and
dead code elimination.
causes a segfault when compiling gcc.c-torture/compile/920917-1.c -O0 for
the SH targets -m2, -m2 -ml, -m3e, -m3e -ml, -m4, -m4 -ml, -m4-single,
-m4-single -ml, -m4-single-only and -m4-single-only -ml .
Just looking at the -m2 case, before jump we have:
============================================================================
(jump_insn 31 30 32 (parallel[
(set (pc)
(plus:SI (reg:SI 58)
(label_ref 0)))
(use (label_ref 33))
] ) -1 (nil)
(nil))
(barrier 32 31 33)
(code_label 33 32 34 8 "" "" [num uses: 0])
(jump_insn 34 33 35 (addr_diff_vec:HI (label_ref:SI 33)
[
(label_ref:SI 16)
(label_ref:SI 17)
(label_ref:SI 15)
(label_ref:SI 15)
(label_ref:SI 17)
(label_ref:SI 13)
]
(const_int 0 [0x0])
(const_int 0 [0x0])) -1 (nil)
(nil))
(barrier 35 34 10)
(note 10 35 13 ("/s/egcs-fpscr2/gcc/testsuite/gcc.c-torture/compile/920917-1.c") 1)
(code_label 13 10 14 4 "" "" [num uses: 0])
(code_label 14 13 15 5 "" "" [num uses: 0])
(code_label 15 14 16 6 "" "" [num uses: 0])
(code_label 16 15 17 7 "" "" [num uses: 0])
(code_label 17 16 36 9 "" "" [num uses: 0])
(code_label 36 17 38 3 "" "" [num uses: 0])
============================================================================
And this is changed into:
============================================================================
(jump_insn 31 30 32 (set (pc)
(label_ref 36)) -1 (nil)
(nil))
(barrier 32 31 33)
(code_label 33 32 34 8 "" "" [num uses: 1])
(jump_insn 34 33 35 (addr_diff_vec:HI (label_ref:SI 33)
[
(label_ref:SI 36)
(label_ref:SI 36)
(label_ref:SI 36)
(label_ref:SI 36)
(label_ref:SI 36)
(label_ref:SI 36)
]
(const_int 0 [0x0])
(const_int 0 [0x0])) -1 (nil)
(nil))
(barrier 35 34 10)
(note 10 35 36 ("/s/egcs-fpscr2/gcc/testsuite/gcc.c-torture/compile/920917-1.c") 1)
(code_label 36 10 38 3 "" "" [num uses: 8])
============================================================================
Note that the insn using the addr_diff_vec gets changed to not use it any
longer, but the addr_diff_vec is kept around.
In redirect_tablejump, there is this code:
if (--LABEL_NUSES (olabel) == 0)
{
delete_labelref_insn (jump, olabel, 0);
delete_insn (olabel);
}
Obviously, this doesn't delete addr_diff_vecs, since their label is
referenced by the addr_diff_vec itself.
Supposedly that was not a problem before because flow removes these
stale addr_diff_vecs, but now that jump optimizations are done even
at -O0, you can no longer rely on that.