<html>
    <head>
      <base href="http://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 --- - Performance regression caused by changes in machine sink"
   href="http://llvm.org/bugs/show_bug.cgi?id=21115">21115</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Performance regression caused by changes in machine sink
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>avolkov.intel@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, wujingyue@gmail.com, zinovy.nis@gmail.com
          </td>
        </tr>

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

After changes in revision 216862 I see performance regression at least on x86
Silvermont on attached test case.
To reproduce compile it with:
llc -O2 -mcpu=slm test.ll

The reason of regression is machine sink doesn't move some add operations out
of loop:

Revision 216861:
    addl    %edx, %ebx
    addl    $1, %esi
    addl    %ebp, %ecx
    cmpl    $512, %ebx              # imm = 0x200
    jl    .LBB0_5                 <--- Back edge
# BB#6:                                 # %for.cond4.for.end_crit_edge
                                        #   in Loop: Header=BB0_4 Depth=2
    movl    20(%esp), %edx          # 4-byte Reload
    leal    (%edx,%ecx), %edi       <--- add moved out of loop 
    movl    16(%esp), %edx          # 4-byte Reload
    movl    %edi, t_run_test.imagHi_1
    leal    (%edx,%ecx), %ebp       <--- add moved out of loop
    movl    %esi, %edx
    movl    %eax, %esi
    movl    12(%esp), %eax          # 4-byte Reload
    movl    %ebp, t_run_test.realHi_1
    addl    %ecx, %eax              <--- add moved out of loop
    addl    8(%esp), %ecx           # 4-byte Folded Reload   <--- add moved out
of loop
    movl    %eax, t_run_test.imagLow_1
    movl    %esi, %eax
    movl    %edx, %esi
    movl    4(%esp), %edx           # 4-byte Reload
    movl    %ecx, t_run_test.realLow_1

Revision 21862:
    cmpl    $512, %ecx              # imm = 0x200
    leal    (%eax,%ebx), %ebp       <--- add inside loop
    movl    24(%esp), %eax          # 4-byte Reload
    leal    (%edx,%ebx), %edx       <--- add inside loop
    leal    (%edi,%ebx), %edi       <--- add inside loop
    leal    (%eax,%ebx), %eax       <--- add inside loop
    jl    .LBB0_5                 <--- Back edge
# BB#6:                                 # %for.cond4.for.end_crit_edge
                                        #   in Loop: Header=BB0_4 Depth=2
    movl    %edi, t_run_test.realLow_1
    movl    %edx, t_run_test.imagLow_1
    movl    %eax, t_run_test.realHi_1
    movl    %ebp, t_run_test.imagHi_1</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>