alias.c [...] (init_alias_analysis, [...]): Use memset () instead of bzero ().
[gcc.git] / gcc / jump.c
index cf4d78d87415a420f32f3313ad56a8d921d8dcdb..4c9c5ea2faed1eace6fd16ede1cd38825c6ecb58 100644 (file)
@@ -19,7 +19,6 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-
 /* This is the jump-optimization pass of the compiler.
    It is run two or three times: once before cse, sometimes once after cse,
    and once after reload (before final).
@@ -96,10 +95,6 @@ static rtx *jump_chain;
 
 static int max_jump_chain;
 
-/* Set nonzero by jump_optimize if control can fall through
-   to the end of the function.  */
-int can_reach_end;
-
 /* Indicates whether death notes are significant in cross jump analysis.
    Normally they are not significant, because of A and B jump to C,
    and R dies in A, it must die in B.  But this might not be true after
@@ -113,7 +108,6 @@ static void delete_barrier_successors       PARAMS ((rtx));
 static void mark_all_labels            PARAMS ((rtx, int));
 static rtx delete_unreferenced_labels  PARAMS ((rtx));
 static void delete_noop_moves          PARAMS ((rtx));
-static int calculate_can_reach_end     PARAMS ((rtx, int));
 static int duplicate_loop_exit_test    PARAMS ((rtx));
 static void find_cross_jump            PARAMS ((rtx, rtx, int, rtx *, rtx *));
 static void do_cross_jump              PARAMS ((rtx, rtx, rtx));
@@ -156,6 +150,7 @@ rebuild_jump_labels (f)
 }
 
 /* Alternate entry into the jump optimizer.  Do only trivial optimizations.  */
+
 void
 jump_optimize_minimal (f)
      rtx f;
@@ -280,7 +275,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
            && REGNO_FIRST_UID (REGNO (SET_DEST (set))) == INSN_UID (insn)
            /* We use regno_last_note_uid so as not to delete the setting
               of a reg that's used in notes.  A subsequent optimization
-              might arrange to use that reg for real.  */             
+              might arrange to use that reg for real.  */
            && REGNO_LAST_NOTE_UID (REGNO (SET_DEST (set))) == INSN_UID (insn)
            && ! side_effects_p (SET_SRC (set))
            && ! find_reg_note (insn, REG_RETVAL, 0)
@@ -374,7 +369,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
                  && dispatch != 0
                  && GET_CODE (dispatch) == JUMP_INSN
                  && JUMP_LABEL (dispatch) != 0
-                 /* Don't mess with a casesi insn. 
+                 /* Don't mess with a casesi insn.
                     XXX according to the comment before computed_jump_p(),
                     all casesi insns should be a parallel of the jump
                     and a USE of a LABEL_REF.  */
@@ -422,7 +417,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
                for (temp2 = insn; temp2 != temp; temp2 = NEXT_INSN (temp2))
                  if (GET_CODE (temp2) == NOTE && NOTE_LINE_NUMBER (temp2) > 0)
                    break;
-                 
+
              if (temp2 == temp)
                {
                  delete_jump (insn);
@@ -553,16 +548,16 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
                   && GET_CODE (PATTERN (temp)) == TRAP_IF
                   && (this_is_any_uncondjump
                       || (this_is_any_condjump
-                          && temp2 = get_condition (insn, &temp4))))
+                          && (temp2 = get_condition (insn, &temp4)))))
            {
              rtx tc = TRAP_CONDITION (PATTERN (temp));
 
              if (tc == const_true_rtx
-                 || (! this_is_uncondjump && rtx_equal_p (temp2, tc)))
+                 || (! this_is_any_uncondjump && rtx_equal_p (temp2, tc)))
                {
                  rtx new;
                  /* Replace an unconditional jump to a trap with a trap.  */
-                 if (this_is_uncondjump)
+                 if (this_is_any_uncondjump)
                    {
                      emit_barrier_after (emit_insn_before (gen_trap (), insn));
                      delete_jump (insn);
@@ -620,8 +615,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
                  /* TARGET is nonzero if it is ok to cross jump
                     to code before TARGET.  If so, see if matches.  */
                  if (x != 0)
-                   find_cross_jump (insn, x,
-                                    (optimize_size ? 1 : BRANCH_COST) + 1,
+                   find_cross_jump (insn, x, 2,
                                     &newjpos, &newlpos);
 
                  if (newjpos != 0)
@@ -658,8 +652,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
 
                  /* TARGET is nonzero if it is ok to cross jump
                     to code before TARGET.  If so, see if matches.  */
-                 find_cross_jump (insn, JUMP_LABEL (insn),
-                                  optimize_size ? 1 : BRANCH_COST,
+                 find_cross_jump (insn, JUMP_LABEL (insn), 1,
                                   &newjpos, &newlpos);
 
                  /* If cannot cross jump to code before the label,
@@ -674,8 +667,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
                          && JUMP_LABEL (target) == JUMP_LABEL (insn)
                          /* Ignore TARGET if it's deleted.  */
                          && ! INSN_DELETED_P (target))
-                       find_cross_jump (insn, target,
-                                        (optimize_size ? 1 : BRANCH_COST) + 1,
+                       find_cross_jump (insn, target, 2,
                                         &newjpos, &newlpos);
 
                  if (newjpos != 0)
@@ -706,8 +698,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
                    if (target != insn
                        && ! INSN_DELETED_P (target)
                        && GET_CODE (PATTERN (target)) == RETURN)
-                     find_cross_jump (insn, target,
-                                      (optimize_size ? 1 : BRANCH_COST) + 1,
+                     find_cross_jump (insn, target, 2,
                                       &newjpos, &newlpos);
 
                  if (newjpos != 0)
@@ -747,13 +738,6 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan,
        }
   }
 
-  /* CAN_REACH_END is persistent for each function.  Once set it should
-     not be cleared.  This is especially true for the case where we
-     delete the NOTE_FUNCTION_END note.  CAN_REACH_END is cleared by
-     the front-end before compiling each function.  */
-  if (! minimal && calculate_can_reach_end (last_insn, optimize != 0))
-    can_reach_end = 1;
-
 end:
   /* Clean up.  */
   free (jump_chain);
@@ -795,7 +779,7 @@ init_label_info (f)
   return largest_uid;
 }
 
-/* Delete insns following barriers, up to next label. 
+/* Delete insns following barriers, up to next label.
 
    Also delete no-op jumps created by gcse.  */
 
@@ -859,7 +843,7 @@ mark_all_labels (f, cross_jump)
   rtx insn;
 
   for (insn = f; insn; insn = NEXT_INSN (insn))
-    if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
+    if (INSN_P (insn))
       {
        if (GET_CODE (insn) == CALL_INSN
            && GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
@@ -869,7 +853,7 @@ mark_all_labels (f, cross_jump)
            mark_all_labels (XEXP (PATTERN (insn), 2), cross_jump);
            continue;
          }
-       
+
        mark_jump_label (PATTERN (insn), insn, cross_jump, 0);
        if (! INSN_DELETED_P (insn) && GET_CODE (insn) == JUMP_INSN)
          {
@@ -898,11 +882,11 @@ delete_unreferenced_labels (f)
   rtx final = NULL_RTX;
   rtx insn;
 
-  for (insn = f; insn; )
+  for (insn = f; insn;)
     {
       if (GET_CODE (insn) == CODE_LABEL
-          && LABEL_NUSES (insn) == 0
-          && LABEL_ALTERNATE_NAME (insn) == NULL)
+         && LABEL_NUSES (insn) == 0
+         && LABEL_ALTERNATE_NAME (insn) == NULL)
        insn = delete_insn (insn);
       else
        {
@@ -923,7 +907,7 @@ delete_noop_moves (f)
 {
   rtx insn, next;
 
-  for (insn = f; insn; )
+  for (insn = f; insn;)
     {
       next = NEXT_INSN (insn);
 
@@ -1047,7 +1031,7 @@ delete_noop_moves (f)
                      || dreg != sreg)
                    break;
                }
-                 
+
              if (i < 0)
                delete_insn (insn);
            }
@@ -1066,66 +1050,6 @@ delete_noop_moves (f)
     }
 }
 
-/* See if there is still a NOTE_INSN_FUNCTION_END in this function.
-   If so indicate that this function can drop off the end by returning
-   1, else return 0.
-
-   CHECK_DELETED indicates whether we must check if the note being
-   searched for has the deleted flag set.
-
-   DELETE_FINAL_NOTE indicates whether we should delete the note
-   if we find it.  */
-
-static int
-calculate_can_reach_end (last, delete_final_note)
-     rtx last;
-     int delete_final_note;
-{
-  rtx insn = last;
-  int n_labels = 1;
-
-  while (insn != NULL_RTX)
-    {
-      int ok = 0;
-
-      /* One label can follow the end-note: the return label.  */
-      if (GET_CODE (insn) == CODE_LABEL && n_labels-- > 0)
-       ok = 1;
-      /* Ordinary insns can follow it if returning a structure.  */
-      else if (GET_CODE (insn) == INSN)
-       ok = 1;
-      /* If machine uses explicit RETURN insns, no epilogue,
-        then one of them follows the note.  */
-      else if (GET_CODE (insn) == JUMP_INSN
-              && GET_CODE (PATTERN (insn)) == RETURN)
-       ok = 1;
-      /* A barrier can follow the return insn.  */
-      else if (GET_CODE (insn) == BARRIER)
-       ok = 1;
-      /* Other kinds of notes can follow also.  */
-      else if (GET_CODE (insn) == NOTE
-              && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END)
-       ok = 1;
-
-      if (ok != 1)
-       break;
-
-      insn = PREV_INSN (insn);
-    }
-
-  /* See if we backed up to the appropriate type of note.  */
-  if (insn != NULL_RTX
-      && GET_CODE (insn) == NOTE
-      && NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_END)
-    {
-      if (delete_final_note)
-       delete_insn (insn);
-      return 1;
-    }
-
-  return 0;
-}
-
 /* LOOP_START is a NOTE_INSN_LOOP_BEG note that is followed by an unconditional
    jump.  Assume that this unconditional jump is to the exit test code.  If
    the code is sufficiently simple, make a copy of it before INSN,
@@ -1265,14 +1189,14 @@ duplicate_loop_exit_test (loop_start)
              NOTE_SOURCE_FILE (copy) = NOTE_SOURCE_FILE (insn);
            }
          break;
-         
+
        case INSN:
          copy = emit_insn_before (copy_insn (PATTERN (insn)), loop_start);
          if (reg_map)
            replace_regs (PATTERN (copy), reg_map, max_reg, 1);
-         
+
          mark_jump_label (PATTERN (copy), copy, 0, 0);
-         
+
          /* Copy all REG_NOTES except REG_LABEL since mark_jump_label will
             make them.  */
          for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
@@ -1293,9 +1217,10 @@ duplicate_loop_exit_test (loop_start)
          if (reg_map && REG_NOTES (copy))
            replace_regs (REG_NOTES (copy), reg_map, max_reg, 1);
          break;
-         
+
        case JUMP_INSN:
-         copy = emit_jump_insn_before (copy_insn (PATTERN (insn)), loop_start);
+         copy = emit_jump_insn_before (copy_insn (PATTERN (insn)),
+                                       loop_start);
          if (reg_map)
            replace_regs (PATTERN (copy), reg_map, max_reg, 1);
          mark_jump_label (PATTERN (copy), copy, 0, 0);
@@ -1305,9 +1230,9 @@ duplicate_loop_exit_test (loop_start)
              if (reg_map)
                replace_regs (REG_NOTES (copy), reg_map, max_reg, 1);
            }
-         
+
          /* If this is a simple jump, add it to the jump chain.  */
-         
+
          if (INSN_UID (copy) < max_jump_chain && JUMP_LABEL (copy)
              && simplejump_p (copy))
            {
@@ -1316,7 +1241,7 @@ duplicate_loop_exit_test (loop_start)
              jump_chain[INSN_UID (JUMP_LABEL (copy))] = copy;
            }
          break;
-         
+
        default:
          abort ();
        }
@@ -1361,7 +1286,7 @@ duplicate_loop_exit_test (loop_start)
   emit_note_before (NOTE_INSN_LOOP_VTOP, exitcode);
 
   delete_insn (next_nonnote_insn (loop_start));
-  
+
   /* Clean up.  */
   if (reg_map)
     free (reg_map);
@@ -1481,7 +1406,7 @@ find_cross_jump (e1, e2, minimum, f1, f2)
 
       p1 = PATTERN (i1);
       p2 = PATTERN (i2);
-       
+
       /* If this is a CALL_INSN, compare register usage information.
         If we don't check this on stack register machines, the two
         CALL_INSNs might be merged leaving reg-stack.c with mismatching
@@ -1779,7 +1704,7 @@ can_reverse_comparison_p (comparison, insn)
   arg0 = XEXP (comparison, 0);
 
   /* Make sure ARG0 is one of the actual objects being compared.  If we
-     can't do this, we can't be sure the comparison can be reversed. 
+     can't do this, we can't be sure the comparison can be reversed.
 
      Handle cc0 and a MODE_CC register.  */
   if ((GET_CODE (arg0) == REG && GET_MODE_CLASS (GET_MODE (arg0)) == MODE_CC)
@@ -1803,7 +1728,7 @@ can_reverse_comparison_p (comparison, insn)
 
       if (! insn)
        return 0;
-       
+
       for (prev = prev_nonnote_insn (insn);
           prev != 0 && GET_CODE (prev) != CODE_LABEL;
           prev = prev_nonnote_insn (prev))
@@ -1831,7 +1756,7 @@ can_reverse_comparison_p (comparison, insn)
 
    WATCH OUT!  reverse_condition is not safe to use on a jump that might
    be acting on the results of an IEEE floating point comparison, because
-   of the special treatment of non-signaling nans in comparisons.  
+   of the special treatment of non-signaling nans in comparisons.
    Use can_reverse_comparison_p to be sure.  */
 
 enum rtx_code
@@ -2096,7 +2021,7 @@ comparison_dominates_p (code1, code2)
       if (code2 == NE)
        return 1;
       break;
-      
+
     default:
       break;
     }
@@ -2117,8 +2042,8 @@ simplejump_p (insn)
 }
 
 /* Return nonzero if INSN is a (possibly) conditional jump
-   and nothing more.  
+   and nothing more.
+
    Use this function is deprecated, since we need to support combined
    branch and compare insns.  Use any_condjump_p instead whenever possible.  */
 
@@ -2135,20 +2060,21 @@ condjump_p (insn)
   x = SET_SRC (x);
   if (GET_CODE (x) == LABEL_REF)
     return 1;
-  else return (GET_CODE (x) == IF_THEN_ELSE
-              && ((GET_CODE (XEXP (x, 2)) == PC
-                   && (GET_CODE (XEXP (x, 1)) == LABEL_REF
-                       || GET_CODE (XEXP (x, 1)) == RETURN))
-                  || (GET_CODE (XEXP (x, 1)) == PC
-                      && (GET_CODE (XEXP (x, 2)) == LABEL_REF
-                          || GET_CODE (XEXP (x, 2)) == RETURN))));
+  else
+    return (GET_CODE (x) == IF_THEN_ELSE
+           && ((GET_CODE (XEXP (x, 2)) == PC
+                && (GET_CODE (XEXP (x, 1)) == LABEL_REF
+                    || GET_CODE (XEXP (x, 1)) == RETURN))
+               || (GET_CODE (XEXP (x, 1)) == PC
+                   && (GET_CODE (XEXP (x, 2)) == LABEL_REF
+                       || GET_CODE (XEXP (x, 2)) == RETURN))));
 
   return 0;
 }
 
 /* Return nonzero if INSN is a (possibly) conditional jump inside a
    PARALLEL.
+
    Use this function is deprecated, since we need to support combined
    branch and compare insns.  Use any_condjump_p instead whenever possible.  */
 
@@ -2221,7 +2147,7 @@ any_uncondjump_p (insn)
 /* Return true when insn is a conditional jump.  This function works for
    instructions containing PC sets in PARALLELs.  The instruction may have
    various other effects so before removing the jump you must verify
-   safe_to_remove_jump_p.
+   onlyjump_p.
 
    Note that unlike condjump_p it returns false for unconditional jumps.  */
 
@@ -2241,7 +2167,7 @@ any_condjump_p (insn)
   b = GET_CODE (XEXP (SET_SRC (x), 2));
 
   return ((b == PC && (a == LABEL_REF || a == RETURN))
-          || (a == PC && (b == LABEL_REF || b == RETURN)));
+         || (a == PC && (b == LABEL_REF || b == RETURN)));
 }
 
 /* Return the label of a conditional jump.  */
@@ -2473,11 +2399,11 @@ mark_jump_label (x, insn, cross_jump, in_mem)
 
     case SYMBOL_REF:
       if (!in_mem)
-        return;
+       return;
 
       /* If this is a constant-pool reference, see if it is a label.  */
       if (CONSTANT_POOL_ADDRESS_P (x))
-        mark_jump_label (get_pool_constant (x), insn, cross_jump, in_mem);
+       mark_jump_label (get_pool_constant (x), insn, cross_jump, in_mem);
       break;
 
     case LABEL_REF:
@@ -2489,7 +2415,7 @@ mark_jump_label (x, insn, cross_jump, in_mem)
 
        /* Ignore remaining references to unreachable labels that
           have been deleted.  */
-        if (GET_CODE (label) == NOTE
+       if (GET_CODE (label) == NOTE
            && NOTE_LINE_NUMBER (label) == NOTE_INSN_DELETED_LABEL)
          break;
 
@@ -2517,7 +2443,8 @@ mark_jump_label (x, insn, cross_jump, in_mem)
                         || NOTE_LINE_NUMBER (next) == NOTE_INSN_FUNCTION_END
                         /* ??? Optional.  Disables some optimizations, but
                            makes gcov output more accurate with -O.  */
-                        || (flag_test_coverage && NOTE_LINE_NUMBER (next) > 0)))
+                        || (flag_test_coverage
+                            && NOTE_LINE_NUMBER (next) > 0)))
              break;
          }
 
@@ -2569,11 +2496,11 @@ mark_jump_label (x, insn, cross_jump, in_mem)
          int eltnum = code == ADDR_DIFF_VEC ? 1 : 0;
 
          for (i = 0; i < XVECLEN (x, eltnum); i++)
-           mark_jump_label (XVECEXP (x, eltnum, i), NULL_RTX, 
-                    cross_jump, in_mem);
+           mark_jump_label (XVECEXP (x, eltnum, i), NULL_RTX,
+                            cross_jump, in_mem);
        }
       return;
-      
+
     default:
       break;
     }
@@ -2684,12 +2611,15 @@ delete_prior_computation (note, insn)
            {
              int dest_regno = REGNO (SET_DEST (pat));
              int dest_endregno
-                   = dest_regno + (dest_regno < FIRST_PSEUDO_REGISTER 
+               = (dest_regno
+                  + (dest_regno < FIRST_PSEUDO_REGISTER
                      ? HARD_REGNO_NREGS (dest_regno,
-                               GET_MODE (SET_DEST (pat))) : 1);
+                                         GET_MODE (SET_DEST (pat))) : 1));
              int regno = REGNO (reg);
-             int endregno = regno + (regno < FIRST_PSEUDO_REGISTER 
-                            ? HARD_REGNO_NREGS (regno, GET_MODE (reg)) : 1);
+             int endregno
+               = (regno
+                  + (regno < FIRST_PSEUDO_REGISTER
+                     ? HARD_REGNO_NREGS (regno, GET_MODE (reg)) : 1));
 
              if (dest_regno >= regno
                  && dest_endregno <= endregno)
@@ -2705,7 +2635,8 @@ delete_prior_computation (note, insn)
                  int i;
 
                  REG_NOTES (our_prev)
-                   = gen_rtx_EXPR_LIST (REG_UNUSED, reg, REG_NOTES (our_prev));
+                   = gen_rtx_EXPR_LIST (REG_UNUSED, reg,
+                                        REG_NOTES (our_prev));
 
                  for (i = dest_regno; i < dest_endregno; i++)
                    if (! find_regno_note (our_prev, REG_UNUSED, i))
@@ -2791,24 +2722,25 @@ delete_computation (insn)
   set = single_set (insn);
   if (set && GET_CODE (SET_DEST (set)) == REG)
     {
-    int dest_regno = REGNO (SET_DEST (set));
-    int dest_endregno
-         = dest_regno + (dest_regno < FIRST_PSEUDO_REGISTER 
-           ? HARD_REGNO_NREGS (dest_regno,
-                               GET_MODE (SET_DEST (set))) : 1);
-    int i;
-
-    for (i = dest_regno; i < dest_endregno; i++)
-      {
-       if (! refers_to_regno_p (i, i + 1, SET_SRC (set), NULL_PTR)
-           || find_regno_note (insn, REG_DEAD, i))
-         continue;
-
-       note = gen_rtx_EXPR_LIST (REG_DEAD, (i < FIRST_PSEUDO_REGISTER
-                                            ? gen_rtx_REG (reg_raw_mode[i], i)
-                                            : SET_DEST (set)), NULL_RTX);
-       delete_prior_computation (note, insn);
-      }
+      int dest_regno = REGNO (SET_DEST (set));
+      int dest_endregno
+       = dest_regno + (dest_regno < FIRST_PSEUDO_REGISTER
+                       ? HARD_REGNO_NREGS (dest_regno,
+                                           GET_MODE (SET_DEST (set))) : 1);
+      int i;
+
+      for (i = dest_regno; i < dest_endregno; i++)
+       {
+         if (! refers_to_regno_p (i, i + 1, SET_SRC (set), NULL_PTR)
+             || find_regno_note (insn, REG_DEAD, i))
+           continue;
+
+         note = gen_rtx_EXPR_LIST (REG_DEAD,
+                                   (i < FIRST_PSEUDO_REGISTER
+                                    ? gen_rtx_REG (reg_raw_mode[i], i)
+                                    : SET_DEST (set)), NULL_RTX);
+         delete_prior_computation (note, insn);
+       }
     }
 
   for (note = REG_NOTES (insn); note; note = next)
@@ -3071,19 +3003,19 @@ never_reached_warning (avoided_insn)
   rtx a_line_note = NULL;
   int two_avoided_lines = 0;
   int contains_insn = 0;
-  
+
   if (! warn_notreached)
     return;
 
   /* Scan forwards, looking at LINE_NUMBER notes, until
      we hit a LABEL or we run out of insns.  */
-  
+
   for (insn = avoided_insn; insn != NULL; insn = NEXT_INSN (insn))
     {
-       if (GET_CODE (insn) == CODE_LABEL)
-        break;
-       else if (GET_CODE (insn) == NOTE                /* A line number note? */ 
-               && NOTE_LINE_NUMBER (insn) >= 0)
+      if (GET_CODE (insn) == CODE_LABEL)
+       break;
+      else if (GET_CODE (insn) == NOTE         /* A line number note?  */
+              && NOTE_LINE_NUMBER (insn) >= 0)
        {
          if (a_line_note == NULL)
            a_line_note = insn;
@@ -3091,8 +3023,8 @@ never_reached_warning (avoided_insn)
            two_avoided_lines |= (NOTE_LINE_NUMBER (a_line_note)
                                  != NOTE_LINE_NUMBER (insn));
        }
-       else if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
-        contains_insn = 1;
+      else if (INSN_P (insn))
+       contains_insn = 1;
     }
   if (two_avoided_lines && contains_insn)
     warning_with_file_and_line (NOTE_SOURCE_FILE (a_line_note),
@@ -3122,7 +3054,7 @@ redirect_exp_1 (loc, olabel, nlabel, insn)
          if (nlabel)
            n = gen_rtx_LABEL_REF (VOIDmode, nlabel);
          else
-           n = gen_rtx_RETURN (VOIDmode); 
+           n = gen_rtx_RETURN (VOIDmode);
 
          validate_change (insn, loc, n, 1);
          return;
@@ -3246,7 +3178,8 @@ redirect_jump (jump, nlabel, delete_unused)
 
   /* If we're eliding the jump over exception cleanups at the end of a
      function, move the function end note so that -Wreturn-type works.  */
-  if (olabel && NEXT_INSN (olabel)
+  if (olabel && nlabel
+      && NEXT_INSN (olabel)
       && GET_CODE (NEXT_INSN (olabel)) == NOTE
       && NOTE_LINE_NUMBER (NEXT_INSN (olabel)) == NOTE_INSN_FUNCTION_END)
     emit_note_after (NOTE_INSN_FUNCTION_END, nlabel);
@@ -3257,7 +3190,7 @@ redirect_jump (jump, nlabel, delete_unused)
   return 1;
 }
 
-/* Invert the jump condition of rtx X contained in jump insn, INSN.  
+/* Invert the jump condition of rtx X contained in jump insn, INSN.
    Accrue the modifications into the change group.  */
 
 static void
@@ -3268,7 +3201,7 @@ invert_exp_1 (insn)
   rtx x = pc_set (insn);
 
   if (!x)
-    abort();
+    abort ();
   x = SET_SRC (x);
 
   code = GET_CODE (x);
@@ -3292,7 +3225,7 @@ invert_exp_1 (insn)
                           1);
          return;
        }
-                                      
+
       tem = XEXP (x, 1);
       validate_change (insn, &XEXP (x, 1), XEXP (x, 2), 1);
       validate_change (insn, &XEXP (x, 2), tem, 1);
@@ -3301,7 +3234,7 @@ invert_exp_1 (insn)
     abort ();
 }
 
-/* Invert the jump condition of conditional jump insn, INSN. 
+/* Invert the jump condition of conditional jump insn, INSN.
 
    Return 1 if we can do so, 0 if we cannot find a way to do so that
    matches a pattern.  */
@@ -3389,7 +3322,8 @@ delete_from_jump_chain (jump)
   /* Handle return insns.  */
   else if (jump_chain && GET_CODE (PATTERN (jump)) == RETURN)
     index = 0;
-  else return;
+  else
+    return;
 
   if (jump_chain[index] == jump)
     jump_chain[index] = jump_chain[INSN_UID (jump)];
@@ -3500,7 +3434,7 @@ rtx_renumbered_equal_p (x, y)
   register int i;
   register RTX_CODE code = GET_CODE (x);
   register const char *fmt;
-      
+
   if (x == y)
     return 1;
 
@@ -3560,7 +3494,7 @@ rtx_renumbered_equal_p (x, y)
       return reg_x >= 0 && reg_x == reg_y && word_x == word_y;
     }
 
-  /* Now we have disposed of all the cases 
+  /* Now we have disposed of all the cases
      in which different rtx codes can match.  */
   if (code != GET_CODE (y))
     return 0;
@@ -3714,7 +3648,7 @@ true_regnum (x)
    In general, if the first test fails, the program can branch
    directly to `foo' and skip the second try which is doomed to fail.
    We run this after loop optimization and before flow analysis.  */
-   
+
 /* When comparing the insn patterns, we track the fact that different
    pseudo-register numbers may have been used in each computation.
    The following array stores an equivalence -- same_regs[I] == J means
@@ -3736,7 +3670,7 @@ static char *modified_regs;
 
 static int modified_mem;
 
-/* Called via note_stores on each insn between the target of the first 
+/* Called via note_stores on each insn between the target of the first
    branch and the second branch.  It marks any changed registers.  */
 
 static void
@@ -3766,7 +3700,7 @@ mark_modified_reg (dest, x, data)
 }
 
 /* F is the first insn in the chain of insns.  */
-   
+
 void
 thread_jumps (f, max_reg, flag_before_loop)
      rtx f;
@@ -3782,7 +3716,7 @@ thread_jumps (f, max_reg, flag_before_loop)
      will either always succeed or always fail depending on the relative
      senses of the two branches.  So adjust the first branch accordingly
      in this case.  */
-     
+
   rtx label, b1, b2, t1, t2;
   enum rtx_code code1, code2;
   rtx b1op0, b1op1, b2op0, b2op1;
@@ -3796,7 +3730,7 @@ thread_jumps (f, max_reg, flag_before_loop)
   all_reset = (int *) xmalloc (max_reg * sizeof (int));
   for (i = 0; i < max_reg; i++)
     all_reset[i] = -1;
-    
+
   while (changed)
     {
       changed = 0;
@@ -3805,12 +3739,13 @@ thread_jumps (f, max_reg, flag_before_loop)
        {
          rtx set;
          rtx set2;
+
          /* Get to a candidate branch insn.  */
          if (GET_CODE (b1) != JUMP_INSN
              || ! any_condjump_p (b1) || JUMP_LABEL (b1) == 0)
            continue;
 
-         bzero (modified_regs, max_reg * sizeof (char));
+         memset (modified_regs, 0, max_reg * sizeof (char));
          modified_mem = 0;
 
          bcopy ((char *) all_reset, (char *) same_regs,
@@ -3894,12 +3829,13 @@ thread_jumps (f, max_reg, flag_before_loop)
              && rtx_equal_for_thread_p (b1op1, b2op1, b2)
              && (comparison_dominates_p (code1, code2)
                  || (can_reverse_comparison_p (XEXP (SET_SRC (set), 0), b1)
-                     && comparison_dominates_p (code1, reverse_condition (code2)))))
+                     && comparison_dominates_p (code1,
+                                                reverse_condition (code2)))))
 
            {
              t1 = prev_nonnote_insn (b1);
              t2 = prev_nonnote_insn (b2);
-             
+
              while (t1 != 0 && t2 != 0)
                {
                  if (t2 == label)
@@ -3915,7 +3851,7 @@ thread_jumps (f, max_reg, flag_before_loop)
                        break;
 
                      if (comparison_dominates_p (code1, code2))
-                       new_label = JUMP_LABEL (b2);
+                       new_label = JUMP_LABEL (b2);
                      else
                        new_label = get_label_after (b2);
 
@@ -3937,7 +3873,7 @@ thread_jumps (f, max_reg, flag_before_loop)
                        }
                      break;
                    }
-                   
+
                  /* If either of these is not a normal insn (it might be
                     a JUMP_INSN, CALL_INSN, or CODE_LABEL) we fail.  (NOTEs
                     have already been skipped above.)  Similarly, fail
@@ -3947,7 +3883,7 @@ thread_jumps (f, max_reg, flag_before_loop)
                      || ! rtx_equal_for_thread_p (PATTERN (t1),
                                                   PATTERN (t2), t2))
                    break;
-                   
+
                  t1 = prev_nonnote_insn (t1);
                  t2 = prev_nonnote_insn (t2);
                }
@@ -3964,7 +3900,7 @@ thread_jumps (f, max_reg, flag_before_loop)
 /* This is like RTX_EQUAL_P except that it knows about our handling of
    possibly equivalent registers and knows to consider volatile and
    modified objects as not equal.
-   
+
    YINSN is the insn containing Y.  */
 
 int
@@ -4028,7 +3964,7 @@ rtx_equal_for_thread_p (x, y, yinsn)
          num_same_regs++;
 
          /* If this is the first time we are seeing a register on the `Y'
-            side, see if it is the last use.  If not, we can't thread the 
+            side, see if it is the last use.  If not, we can't thread the
             jump, so mark it as not equivalent.  */
          if (REGNO_LAST_UID (REGNO (y)) != INSN_UID (yinsn))
            return 0;
@@ -4060,7 +3996,7 @@ rtx_equal_for_thread_p (x, y, yinsn)
       if (GET_CODE (SET_DEST (x)) == REG
           && GET_CODE (SET_DEST (y)) == REG)
        {
-          if (same_regs[REGNO (SET_DEST (x))] == (int) REGNO (SET_DEST (y)))
+         if (same_regs[REGNO (SET_DEST (x))] == (int) REGNO (SET_DEST (y)))
            {
              same_regs[REGNO (SET_DEST (x))] = -1;
              num_same_regs--;
@@ -4069,8 +4005,10 @@ rtx_equal_for_thread_p (x, y, yinsn)
            return 0;
        }
       else
-       if (rtx_equal_for_thread_p (SET_DEST (x), SET_DEST (y), yinsn) == 0)
-         return 0;
+       {
+         if (rtx_equal_for_thread_p (SET_DEST (x), SET_DEST (y), yinsn) == 0)
+           return 0;
+       }
 
       return rtx_equal_for_thread_p (SET_SRC (x), SET_SRC (y), yinsn);
 
@@ -4079,7 +4017,7 @@ rtx_equal_for_thread_p (x, y, yinsn)
 
     case SYMBOL_REF:
       return XSTR (x, 0) == XSTR (y, 0);
-      
+
     default:
       break;
     }
@@ -4112,7 +4050,7 @@ rtx_equal_for_thread_p (x, y, yinsn)
          /* And the corresponding elements must match.  */
          for (j = 0; j < XVECLEN (x, i); j++)
            if (rtx_equal_for_thread_p (XVECEXP (x, i, j),
-                                       XVECEXP (y, i, j), yinsn) == 0)
+                                       XVECEXP (y, i, j), yinsn) == 0)
              return 0;
          break;