Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 12 Feb 2015 20:26:27 +0100
From: Denys Vlasenko <vda.linux@...glemail.com>
To: musl <musl@...ts.openwall.com>
Subject: Re: [PATCH 1/2] x86_64/memset: avoid multiply insn if possible

On Thu, Feb 12, 2015 at 6:27 PM, Rich Felker <dalias@...c.org> wrote:
> On Thu, Feb 12, 2015 at 06:17:02PM +0100, Denys Vlasenko wrote:
>> memset is very, very often called with fill=0,
>> and 64-bit imul is expensive on many CPUs.
>> Avoid it if fill=0.
>>
>> Also avoid multiply on "short memset" codepath if possible,
>> and when we do need it, use 32-bit one, which is cheaper on many CPUs.
>
> I'd actually like to extend the "short" range up to at least 32 bytes
> using two 8-byte writes for the middle, unless the savings from using
> 32-bit imul instead of 64-bit are sufficient to justify 4 4-byte
> writes for the middle. On the cpu I tested on, the difference is 11
> cycles vs 32 cycles for non-rep path versus rep path at size 32.

The short path causes mixed feelings in me.

On one hand, it's elegant in a contrived way.

On the other hand, multiple
overlaying stores must be causing hell in store unit.
I'm thinking, maybe there's a faster way to do that.

Can you post your memset testsuite?

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.