On Fri, Nov 29, 2013 at 12:14 PM, Richard Sandiford
<rdsandif...@googlemail.com> wrote:
> In the fold-const.ii testcase, well over half of the mul_internal calls
> were for multiplication by 0 (106038 out of 169355).  This patch adds
> an early-out for that.
>
> Tested on x86_64-linux-gnu.  OK to install?

Ok.  Did you check how many of the remaining are multiplies by 1?

Thanks,
Richard.

> Thanks,
> Richard
>
>
> Index: gcc/wide-int.cc
> ===================================================================
> --- gcc/wide-int.cc     2013-11-29 10:50:46.594705157 +0000
> +++ gcc/wide-int.cc     2013-11-29 11:06:50.052557006 +0000
> @@ -1289,6 +1289,13 @@ wi::mul_internal (HOST_WIDE_INT *val, co
>    if (needs_overflow)
>      *overflow = false;
>
> +  /* This is a surprisingly common case, so do it first.  */
> +  if ((op1len == 1 && op1[0] == 0) || (op2len == 1 && op2[0] == 0))
> +    {
> +      val[0] = 0;
> +      return 1;
> +    }
> +
>    /* If we need to check for overflow, we can only do half wide
>       multiplies quickly because we need to look at the top bits to
>       check for the overflow.  */
>

Reply via email to