From a30c5ca4c15956697b2c78460be0a34811a2106e Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Thu, 17 Dec 2015 10:53:43 +0000 Subject: [PATCH] arc.c (arc_loop_hazard): Don't convert the jump label rtx to an rtx_insn until we confirm it's not a... 2015-12-17 Andrew Burgess gcc: * config/arc/arc.c (arc_loop_hazard): Don't convert the jump label rtx to an rtx_insn until we confirm it's not a return rtx. gcc/testsuite: * gcc.target/arc/loop-hazard-1.c: New file From-SVN: r231752 --- gcc/ChangeLog | 5 +++++ gcc/config/arc/arc.c | 15 ++++++++------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/arc/loop-hazard-1.c | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arc/loop-hazard-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d992910f393..375ab755e80 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-12-17 Andrew Burgess + + * config/arc/arc.c (arc_loop_hazard): Don't convert the jump label + rtx to an rtx_insn until we confirm it's not a return rtx. + 2015-12-17 Richard Biener * gimple-ssa.h (struct gimple_df): Remove modified_noreturn_calls diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 513d138780d..d3a6f27332a 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -8041,6 +8041,7 @@ static bool arc_loop_hazard (rtx_insn *pred, rtx_insn *succ) { rtx_insn *jump = NULL; + rtx label_rtx = NULL_RTX; rtx_insn *label = NULL; basic_block succ_bb; @@ -8067,22 +8068,22 @@ arc_loop_hazard (rtx_insn *pred, rtx_insn *succ) else return false; - label = JUMP_LABEL_AS_INSN (jump); - if (!label) - return false; - /* Phase 2b: Make sure is not a millicode jump. */ if ((GET_CODE (PATTERN (jump)) == PARALLEL) && (XVECEXP (PATTERN (jump), 0, 0) == ret_rtx)) return false; - /* Phase 2c: Make sure is not a simple_return. */ - if ((GET_CODE (PATTERN (jump)) == SIMPLE_RETURN) - || (GET_CODE (label) == SIMPLE_RETURN)) + label_rtx = JUMP_LABEL (jump); + if (!label_rtx) + return false; + + /* Phase 2c: Make sure is not a return. */ + if (ANY_RETURN_P (label_rtx)) return false; /* Pahse 2d: Go to the target of the jump and check for aliveness of LP_COUNT register. */ + label = safe_as_a (label_rtx); succ_bb = BLOCK_FOR_INSN (label); if (!succ_bb) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 054bdf790f9..674c868cf11 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -10,6 +10,10 @@ * gcc.dg/darwin-20040809-2.c: Likewise. * objc.dg/stabs-1.m: Likewise. +2015-12-17 Andrew Burgess + + * gcc.target/arc/loop-hazard-1.c: New file. + 2015-12-17 Andrew Burgess * gcc.target/arc/jump-around-jump.c (rtc_set_time): Declare. diff --git a/gcc/testsuite/gcc.target/arc/loop-hazard-1.c b/gcc/testsuite/gcc.target/arc/loop-hazard-1.c new file mode 100644 index 00000000000..7c688bbc236 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/loop-hazard-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +/* This caused an assertion within arc_loop_hazard. */ + +unsigned a, b; + +long fn1() +{ + long c = 1, d = 0; + while (a && c && b) + c <<= 1; + while (c) + d |= c; + return d; +} -- 2.30.2