Bernd Schmidt <ber...@codesourcery.com> writes:
>>> -  for (; insn; insn = next)
>>> +  for (; insn && !ANY_RETURN_P (insn); insn = next)
>>>      {
>>>        if (NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
>>>     insn = XVECEXP (PATTERN (insn), 0, 0);
>> 
>> Since ANY_RETURN looks for patterns, while this loop iterates over insns,
>> I think it'd be more obvious to have:
>> 
>>   if (insn && ANY_RETURN_P (insn))
>>     return 1;
>> 
>> above the loop instead
>
> That alone wouldn't work since we assign JUMP_LABELs to next.

Doh

> Left alone for now.

OK.

>> This pattern came up in reorg.c too, so maybe it would be worth having
>> a jump_to_label_p inline function somewhere, such as:
>
> Done. Only has two uses for now though; reorg.c uses different patterns
> mostly.

There are a few other natural uses too though (below).

>>> @@ -1195,6 +1195,9 @@ duplicate_insn_chain (rtx from, rtx to)
>>>           break;
>>>         }
>>>       copy = emit_copy_of_insn_after (insn, get_last_insn ());
>>> +     if (JUMP_P (insn) && JUMP_LABEL (insn) != NULL_RTX
>>> +         && ANY_RETURN_P (JUMP_LABEL (insn)))
>>> +       JUMP_LABEL (copy) = JUMP_LABEL (insn);
>> 
>> I think this should go in emit_copy_of_insn_after instead.
>
> Here I'd like to avoid modifying the existing code in
> emit_copy_of_insn_after if possible. Not sure why it's not copying
> JUMP_LABELS, but that's something I'd prefer to investigate at some
> other time rather than risk breaking things.

OK.

> New patch below. Retested on i686-linux and mips64-elf. Ok?

Looks good to me, thanks.  OK with:

> @@ -2757,7 +2770,8 @@ fill_slots_from_thread (rtx insn, rtx co
>                             gcc_assert (REG_NOTE_KIND (note)
>                                         == REG_LABEL_OPERAND);
>                         }
> -                   if (JUMP_P (trial) && JUMP_LABEL (trial))
> +                   if (JUMP_P (trial) && JUMP_LABEL (trial)
> +                       && !ANY_RETURN_P (JUMP_LABEL (trial)))
>                       LABEL_NUSES (JUMP_LABEL (trial))++;

jump_to_label_p here.

> @@ -2776,7 +2790,8 @@ fill_slots_from_thread (rtx insn, rtx co
>                             gcc_assert (REG_NOTE_KIND (note)
>                                         == REG_LABEL_OPERAND);
>                         }
> -                   if (JUMP_P (trial) && JUMP_LABEL (trial))
> +                   if (JUMP_P (trial) && JUMP_LABEL (trial)
> +                       && !ANY_RETURN_P (JUMP_LABEL (trial)))
>                       LABEL_NUSES (JUMP_LABEL (trial))--;

and here.

> Index: gcc/config/sh/sh.c
> ===================================================================
> --- gcc/config/sh/sh.c        (revision 176838)
> +++ gcc/config/sh/sh.c        (working copy)
> @@ -5276,7 +5276,8 @@ barrier_align (rtx barrier_or_label)
>       }
>        if (prev
>         && JUMP_P (prev)
> -       && JUMP_LABEL (prev))
> +       && JUMP_LABEL (prev) != NULL_RTX
> +       && !ANY_RETURN_P (JUMP_LABEL (prev)))
>       {
>         rtx x;
>         if (jump_to_next

and here.

> Index: gcc/config/arm/arm.c
> ===================================================================
> --- gcc/config/arm/arm.c      (revision 176838)
> +++ gcc/config/arm/arm.c      (working copy)
> @@ -11479,6 +11479,7 @@ is_jump_table (rtx insn)
>  
>    if (GET_CODE (insn) == JUMP_INSN
>        && JUMP_LABEL (insn) != NULL
> +      && !ANY_RETURN_P (JUMP_LABEL (insn))
>        && ((table = next_real_insn (JUMP_LABEL (insn)))
>         == next_real_insn (insn))

and here.

Richard

Reply via email to