On Fri, Mar 04, 2016 at 10:59:48AM +0100, Uros Bizjak wrote:
> I don't like the fact that *dynamic_check is set to max (which is 0
> with your testcase) when recursion avoidance code already set it to
> "something reasonable", together with loop_1_byte alg. What do you
> think about attached (lightly tested) patch?

But that can still set *dynamic_check to 0 if the recursive call has
not set *dynamic_check.
So, perhaps we want *dynamic_check = max ? max : 128;
?

> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 8a026ae..ded9951 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -26170,11 +26170,22 @@ decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT 
> expected_size,
>          }
>        alg = decide_alg (count, new_expected_size, min_size, max_size, memset,
>                       zero_memset, have_as, dynamic_check, noalign);
> -      gcc_assert (*dynamic_check == -1);
> +
>        if (TARGET_INLINE_STRINGOPS_DYNAMICALLY)
> -     *dynamic_check = max;
> +     {
> +       /* *dynamic_check could be set to 128 above because we avoided
> +          infinite recursion.  */
> +       if (*dynamic_check == 128)
> +         gcc_assert (alg == loop_1_byte);
> +       else
> +         {
> +           gcc_assert (*dynamic_check == -1);
> +           *dynamic_check = max;
> +         }
> +     }
>        else
> -     gcc_assert (alg != libcall);
> +     gcc_assert (alg != libcall && *dynamic_check == -1);
> +
>        return alg;
>      }
>    return (alg_usable_p (algs->unknown_size, memset, have_as)


        Jakub

Reply via email to