<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Registers are moved around in do{}while(); loop"
   href="https://llvm.org/bugs/show_bug.cgi?id=23202">23202</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Registers are moved around in do{}while(); loop
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>www.kostantinaras@yahoo.gr
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14189" name="attach_14189" title="The whole function">attachment 14189</a> <a href="attachment.cgi?id=14189&action=edit" title="The whole function">[details]</a></span>
The whole function

The loop:
        do{
            previous = next;
            in_pos++;
            *out_pos++ = previous;
            if(in_pos == in_limit)
                goto end;
            next = *in_pos;
        }while(previous != next);

is translateted with -O2 to:

.LBB0_3:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
    #DEBUG_VALUE: xrle_compress:out <- R14
    #DEBUG_VALUE: xrle_compress:repeat <- 1
    mov    rax, rdi
    mov    rcx, rsi
    mov    r13, rdx
    add    r13, 16
    mov    qword ptr [rbx], rax
    cmp    r12, rcx
    je    .LBB0_4
# BB#7:                                 #   in Loop: Header=BB0_3 Depth=2
    #DEBUG_VALUE: xrle_compress:out <- R14
    #DEBUG_VALUE: xrle_compress:repeat <- 1
    mov    rdi, qword ptr [rcx]
    #DEBUG_VALUE: xrle_compress:next <- RDI
    lea    rsi, qword ptr [rcx + 8]
    cmp    rax, rdi
    mov    rdx, rbx
    mov    rbx, r13
    jne    .LBB0_3

Notice how many mov instructions are used:</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>