This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, rtl]: Fix PR rtl-optimization/35604


"Uros Bizjak" <ubizjak@gmail.com> writes:

> Index: jump.c
> ===================================================================
> --- jump.c	(revision 136888)
> +++ jump.c	(working copy)
> @@ -1290,7 +1290,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rt
>  {
>    rtx x = *loc;
>    RTX_CODE code = GET_CODE (x);
> -  int i;
> +  int skip, i;
>    const char *fmt;
>  
>    if (code == LABEL_REF)
> @@ -1327,8 +1327,13 @@ redirect_exp_1 (rtx *loc, rtx olabel, rt
>        return;
>      }
>  
> +  /* Skip the first operand of IF_THEN_ELSE insn.  We should not
> +     change OLABEL to NLABEL, if it is an operand to compare
> +     against in the compare-and-branch instruction.  */
> +  skip = code == IF_THEN_ELSE;
> +
>    fmt = GET_RTX_FORMAT (code);
> -  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
> +  for (i = GET_RTX_LENGTH (code) - 1; i >= skip; i--)
>      {
>        if (fmt[i] == 'e')
>  	redirect_exp_1 (&XEXP (x, i), olabel, nlabel, insn);


I would prefer to see this written in a slightly less tricky way,
something like:

  if (code == IF_THEN_ELSE)
    {
      /* Skip the condition of an IF_THEN_ELSE.  We only want to
         change jump destinations, not label comparisons.  */
      redirect_exp_1 (&XEXP (x, 1), olabel, nlabel, insn);
      redirect_exp_1 (&XEXP (x, 2), olabel, nlabel, insn);
      return;
    }

A patch along those lines is OK if it passes bootstrap and testing.

Thanks.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]