[llvm] r204829 - Revert "X86 memcpy lowering: use "rep movs" even when esi is used as base pointer" (r204174)

Hans Wennborg hans at chromium.org
Thu Apr 24 15:19:58 PDT 2014

Apologies for the huge delay.

If I re-apply my patch and compile the attached bitcode like this:

  clang -target i386-pc-windows-msvc -Os -S -o - a.ll

and search for "rep;movsl", the problem shows up on line 90:

  movl $15, %ecx
  movl %esi, %edx
  movl %ebx, %esi
  leal 116(%esi), %ecx <-- oops
  addl $60, %ebx
  movl %edx, %esi <-- this should come right after the rep movs

I'll see if I can reduce this to something easier to work with. I just
wanted to get the file out before I forgot.

 - Hans

On Wed, Mar 26, 2014 at 12:56 PM, Hans Wennborg <hans at chromium.org> wrote:
> I don't have anything handy, this was from a chrome build. I'll try to
> get something reduced or some bitcode because I'm curious too :)
> On Wed, Mar 26, 2014 at 11:08 AM, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>> Do you have a testcase? I am somewhat curious as to what was causing the bug.
>> On 26 March 2014 12:30, Hans Wennborg <hans at hanshq.net> wrote:
>>> Author: hans
>>> Date: Wed Mar 26 11:30:54 2014
>>> New Revision: 204829
>>> URL: http://llvm.org/viewvc/llvm-project?rev=204829&view=rev
>>> Log:
>>> Revert "X86 memcpy lowering: use "rep movs" even when esi is used as base pointer" (r204174)
>>>>  For functions where esi is used as base pointer, we would previously fall ba
>>>>  from lowering memcpy with "rep movs" because that clobbers esi.
>>>>  With this patch, we just store esi in another physical register, and restore
>>>>  it afterwards. This adds a little bit of register preassure, but the more
>>>>  efficient memcpy should be worth it.
>>>>  Differential Revision: http://llvm-reviews.chandlerc.com/D2968
>>> This didn't work. I was ending up with code like this:
>>>   lea     edi,[esi+38h]
>>>   mov     ecx,0Fh
>>>   mov     edx,esi
>>>   mov     esi,ebx
>>>   rep movs dword ptr es:[edi],dword ptr [esi]
>>>   lea     ecx,[esi+74h] <-- Ooops, we're now using esi before restoring it from edx.
>>>   add     ebx,3Ch
>>>   mov     esi,edx
>>> I guess if we want to do this we need stronger glue or something, or doing the expansion
>>> much later.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.ll.gz
Type: application/x-gzip
Size: 37990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140424/346bd08c/attachment.bin>

More information about the llvm-commits mailing list