<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 --- - Reassociate: Unable to do reassociation"
   href="http://llvm.org/bugs/show_bug.cgi?id=22487">22487</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Reassociate: Unable to do reassociation
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.6
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>swpenim@gmail.com
          </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>Consider the sample code in the following section.
a, b, d, e are all multiplied by -6, and therefore can be added first
before being multiplied. This is done in llvm-3.5 release, but not in git
branch release_36.

sample code
====
int foo(int a, int b, int c, int d, int e)
{
  return -6 * a + -6 * b + 10 * c + -6 *d + -6 *e;
}
====

IR Dump After "Reassociate expressions" in git branch:release_36
===
define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) #0 {
entry:
  %mul8 = add i32 %b, %a
  %add = mul nsw i32 %mul8, 6
  %mul2 = mul nsw i32 %c, 10
  %add.neg = sub i32 0, %add
  %add39 = add i32 %mul2, %add.neg
  %mul4 = mul nsw i32 %d, 6
  %mul4.neg = sub i32 0, %mul4
  %add510 = add i32 %add39, %mul4.neg
  %mul6 = mul nsw i32 %e, 6
  %add711 = sub i32 %add510, %mul6
  ret i32 %add711
}   
===

IR Dump After "Reassociate expressions" in llvm-3.5 release
===
; Function Attrs: nounwind readnone uwtable
define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) #0 {
entry:
  %mul8 = add i32 %b, %a
  %mul2 = mul nsw i32 %c, 10
  %tmp = add i32 %mul8, %d
  %tmp9 = add i32 %tmp, %e
  %tmp10 = mul i32 %tmp9, -6
  %add7 = add i32 %tmp10, %mul2
  ret i32 %add7
}
===</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>