<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Feb 9, 2011, at 5:02 AM, Vasiliy Korchagin wrote:</div><blockquote type="cite"><div text="#000000" bgcolor="#ffffff">llvm emits code for "memcpy" on ARM as consecutive ldr/str commands<span class="Apple-style-span" style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: arial,sans-serif; font-size: 13px;
        white-space: nowrap;"></span></span>, and further combines them
    into ldm/stm with special pass after register allocation. But
    ldm/stm commands require registers to go in ascending order, what is
    often not so after regalloc, therefore some str/ldr commands. For
    example such code:<br>
    <br>
    struct Foo {int a, b, c, d; }<br>
    void CopyStruct(struct Foo *a, struct Foo *b) { *a = *b; }<br>
    <br>
    compiled to:<br>
    <br>
    ldmia    r1, {r2, r3, r12}<br>
    ldr    r1, [r1, #12]<br>
    stmia    r0, {r2, r3, r12}<br>
    str    r1, [r0, #12]<br>
    bx    lr<br>
    <br>
    I ran different tests and always regalloc allocates at least one
    register not in ascending order. <br>
    <br>
    What is your ideas to overcome this issue? Maybe llvm should emit
    code for "memcpy" straight into ldm/stm or exchange registers before
    combining ldr/str to make them go in ascending order or fix somehow
    register allocator?<br></div></blockquote></div><br><div>Hi Vasiliy,</div><div><br></div><div>We should handle this better. I'm not sure how to guarantee that we can generate ldm/stm without regalloc support. Our only idea is to teach the new register allocator to do a much better job satisfying register hints. If you'd like to track this, feel free to file a bug.</div><div><br></div><div>Thanks,</div><div>-Andy</div></body></html>