From bb81a576f259256b38d46dd41d3bd5f5a36cfd6f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 3 Oct 2017 11:49:37 +0200 Subject: [PATCH] re PR target/82386 (internal compiler error: Segmentation fault on 32-bit powerpc BE targets) PR target/82386 * combine.c (combine_instructions): Don't combine in unreachable basic blocks. * gcc.dg/pr82386.c: New test. From-SVN: r253378 --- gcc/ChangeLog | 6 ++++++ gcc/combine.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr82386.c | 38 ++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr82386.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c0b2f2b1c6d..934dd76fa85 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-10-03 Jakub Jelinek + + PR target/82386 + * combine.c (combine_instructions): Don't combine in unreachable + basic blocks. + 2017-08-18 Peter Bergner PR target/80210 diff --git a/gcc/combine.c b/gcc/combine.c index e502fa14726..400cef3495a 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -1232,6 +1232,12 @@ combine_instructions (rtx_insn *f, unsigned int nregs) FOR_EACH_BB_FN (this_basic_block, cfun) { rtx_insn *last_combined_insn = NULL; + + /* Ignore instruction combination in basic blocks that are going to + be removed as unreachable anyway. See PR82386. */ + if (EDGE_COUNT (this_basic_block->preds) == 0) + continue; + optimize_this_for_speed_p = optimize_bb_for_speed_p (this_basic_block); last_call_luid = 0; mem_last_set = -1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 004af663545..74023abc015 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-03 Jakub Jelinek + + PR target/82386 + * gcc.dg/pr82386.c: New test. + 2017-10-02 Paolo Carlini PR c++/70570 diff --git a/gcc/testsuite/gcc.dg/pr82386.c b/gcc/testsuite/gcc.dg/pr82386.c new file mode 100644 index 00000000000..8901f2b4cc7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr82386.c @@ -0,0 +1,38 @@ +/* PR target/82386 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ +/* { dg-additional-options "-misel" { target powerpc*-*-* } } */ + +long long int fs; +int vm; + +void +sd (void) +{ + fs = 1; + vm = 2; + goto zf; + + if (0) + { + int y6 = 0; + int *uu = &y6; + short int he; + int of = 0; + + zf: + for (;;) + { + he = of; + if (he || (fs |= vm)) + { + *uu = fs; + fs += vm; + } + if (y6 == vm) + fs |= he; + he = y6 || fs; + fs /= 0; + } + } +} -- 2.30.2