https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431

--- Comment #4 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Richard Biener from comment #1)
> I can't reproduce in my dev tree but I guess the following will fix it?
> 
> diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
> index 7555793948e..f3efd1ef4b2 100644
> --- a/gcc/tree-ssa-math-opts.cc
> +++ b/gcc/tree-ssa-math-opts.cc
> @@ -1495,7 +1495,7 @@ powi_cost (HOST_WIDE_INT n)
>  
>  static tree
>  powi_as_mults_1 (gimple_stmt_iterator *gsi, location_t loc, tree type,
> -                HOST_WIDE_INT n, tree *cache)
> +                unsigned HOST_WIDE_INT n, tree *cache)
>  {
>    tree op0, op1, ssa_target;
>    unsigned HOST_WIDE_INT digit;
> @@ -1548,7 +1548,7 @@ powi_as_mults (gimple_stmt_iterator *gsi, location_t
> loc,
>    memset (cache, 0, sizeof (cache));
>    cache[1] = arg0;
>  
> -  result = powi_as_mults_1 (gsi, loc, type, (n < 0) ? -n : n, cache);
> +  result = powi_as_mults_1 (gsi, loc, type, absu_hwi (n), cache);
>    if (n >= 0)
>      return result;


Thank you, I missed that "(n < 0) ? -n : n" in the code...
I can confirm the compiler bootstraps, and no longer crashes on the testcase.
I didn't try to run the testsuite.

Reply via email to