+2015-12-17  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * 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  <rguenther@suse.de>
 
        * gimple-ssa.h (struct gimple_df): Remove modified_noreturn_calls
 
 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;
 
   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 <rtx_insn *> (label_rtx);
   succ_bb = BLOCK_FOR_INSN (label);
   if (!succ_bb)
     {
 
        * gcc.dg/darwin-20040809-2.c: Likewise.
        * objc.dg/stabs-1.m: Likewise.
 
+2015-12-17  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gcc.target/arc/loop-hazard-1.c: New file.
+
 2015-12-17  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gcc.target/arc/jump-around-jump.c (rtc_set_time): Declare.