[LLVMbugs] [Bug 22487] New: Reassociate: Unable to do reassociation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 5 23:57:28 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22487

            Bug ID: 22487
           Summary: Reassociate: Unable to do reassociation
           Product: libraries
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: swpenim at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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
}
===

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150206/a5fcb0ca/attachment.html>


More information about the llvm-bugs mailing list