From: Randolph Chung Date: Thu, 20 Feb 2003 20:11:04 +0000 (+0000) Subject: re PR rtl-optimization/9768 ([HP-PA] ICE when optimizing inline code at -O2) X-Git-Tag: releases/gcc-3.2.3~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a7661bb983e3a1cbd0792bd636c760a62df6d1b;p=thirdparty%2Fgcc.git re PR rtl-optimization/9768 ([HP-PA] ICE when optimizing inline code at -O2) PR optimization/9768 Backport patch from mainline: 2002-03-21 DJ Delorie * bb-reorder.c (make_reorder_chain_1): Protect against when redundant edges are omitted. * predict.c (dump_prediction): Likewise. Co-Authored-By: Eric Botcazou From-SVN: r63180 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb7fb2c2a6d5..13bcb1af571d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2003-02-20 Randolph Chung + Eric Botcazou + + PR optimization/9768 + Backport patch from mainline: + + 2002-03-21 DJ Delorie + + * bb-reorder.c (make_reorder_chain_1): Protect against + when redundant edges are omitted. + * predict.c (dump_prediction): Likewise. + 2003-02-20 BAN Nobuhiro PR c/9678 diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index b0cc46215ea6..9a25281d8409 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -205,7 +205,7 @@ make_reorder_chain_1 (bb, prev) e_taken = e; } - next = (taken ? e_taken : e_fall)->dest; + next = ((taken && e_taken) ? e_taken : e_fall)->dest; } /* In the absence of a prediction, disturb things as little as possible diff --git a/gcc/predict.c b/gcc/predict.c index bcafef2692ac..8f2a08388da4 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -194,7 +194,7 @@ dump_prediction (predictor, probability, bb, used) if (!rtl_dump_file) return; - while (e->flags & EDGE_FALLTHRU) + while (e && (e->flags & EDGE_FALLTHRU)) e = e->succ_next; fprintf (rtl_dump_file, " %s heuristics%s: %.1f%%", @@ -205,9 +205,12 @@ dump_prediction (predictor, probability, bb, used) { fprintf (rtl_dump_file, " exec "); fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, bb->count); - fprintf (rtl_dump_file, " hit "); - fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, e->count); - fprintf (rtl_dump_file, " (%.1f%%)", e->count * 100.0 / bb->count); + if (e) + { + fprintf (rtl_dump_file, " hit "); + fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, e->count); + fprintf (rtl_dump_file, " (%.1f%%)", e->count * 100.0 / bb->count); + } } fprintf (rtl_dump_file, "\n"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2616ac3db634..f82d3a37f650 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-02-20 Randolph Chung + + * gcc.c-torture/compile/20030220-1.c: New test. + 2003-02-19 Kriang Lerdsuwanakij PR c++/9459 diff --git a/gcc/testsuite/gcc.c-torture/compile/20030220-1.c b/gcc/testsuite/gcc.c-torture/compile/20030220-1.c new file mode 100644 index 000000000000..59a03e42c456 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20030220-1.c @@ -0,0 +1,20 @@ +/* PR optimization/9768 */ +/* Originator: Randolph Chung */ + +inline int fixfloor (long x) +{ + if (x >= 0) + return (x >> 16); + else + return ~((~x) >> 16); +} + +inline int fixtoi (long x) +{ + return fixfloor(x) + ((x & 0x8000) >> 15); +} + +int foo(long x, long y) +{ + return fixtoi(x*y); +}