Richard Sandiford <rdsandif...@googlemail.com> wrote:
>Richard Biener <richard.guent...@gmail.com> writes:
>> 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?
>
>Turns out to be 9685, which is probably enough to justify a special
>case.
>
>Tested on x86_64-linux-gnu.  OK to install?

Ok.  I assume we already have a special.case for division by 1?

Thanks,
Richard.

>Thanks,
>Richard
>
>
>Index: gcc/wide-int.cc
>===================================================================
>--- gcc/wide-int.cc    2013-11-29 15:04:41.177142418 +0000
>+++ gcc/wide-int.cc    2013-11-29 15:05:36.482424592 +0000
>@@ -1296,6 +1296,20 @@ wi::mul_internal (HOST_WIDE_INT *val, co
>       return 1;
>     }
> 
>+  /* Handle multiplications by 1.  */
>+  if (op1len == 1 && op1[0] == 1)
>+    {
>+      for (i = 0; i < op2len; i++)
>+      val[i] = op2[i];
>+      return op2len;
>+    }
>+  if (op2len == 1 && op2[0] == 1)
>+    {
>+      for (i = 0; i < op1len; i++)
>+      val[i] = op1[i];
>+      return op1len;
>+    }
>+
>   /* 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