This is an archive of the discontinued LLVM Phabricator instance.

Move memset value into register
AbandonedPublic

Authored by sepavloff on Aug 22 2013, 10:37 PM.

Details

Reviewers
nadav
bkramer
Summary

This patch fixes PR5124 (memset inline-code threshold dubiously high).
If memset is expanded inline and the memset value is constant, code generator created sequence of instructions 'mov imm, mem', like:

movl   $0x0,0x4(%esi)
movl   $0x0,0x8(%esi)

With this patch the memset value is put into register and then instructions 'mov reg, mem' are used:

movl   %eax,0x4(%esi)
movl   %eax,0x8(%esi)

It is profitable for both speed and code size, gcc and icc expand memset in this way.

Could you please review the patch?
Thank you.

Diff Detail

Event Timeline

Thanks for working on this, it nicely avoids the bloated code of the immediate form of "mov".

The patch essentially looks good to me as is. I'd like to hear a second opinion from Nadav in case I'm missing something.

sepavloff updated this revision to Unknown Object (????).Sep 10 2013, 2:43 AM

Cosmetical update to the patch
If block size is small, the size of largest move chunk may be smaller than the
natural register width and target may not have resisters of such width. Example
is 32-bit target that does not have 16-bit registers. Avoid allocation such
illegal registers.

void added a subscriber: void.Mar 5 2022, 5:31 PM

@sepavloff, are you still interested in this patch? I've been going through old bugs...

Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2022, 5:31 PM
Herald added a subscriber: pengfei. · View Herald Transcript
sepavloff abandoned this revision.Mar 5 2022, 10:26 PM
In D1484#3362129, @void wrote:

@sepavloff, are you still interested in this patch? I've been going through old bugs...

No, this patch is outdated.