[LLVMbugs] [Bug 21768] New: reassociate multiplies with fast-math

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 5 11:50:55 PST 2014


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

            Bug ID: 21768
           Summary: reassociate multiplies with fast-math
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

define float @foo(float %f0, float %f1, float %f2, float %f3) {
  %mul0 = fmul fast float %f1, %f0
  %mul1 = fmul fast float %mul0, %f2
  %mul2 = fmul fast float %mul1, %f3
  ret float %mul2
}

This should be optimized to:

define float @foo(float %f0, float %f1, float %f2, float %f3) {
  %mul0 = fmul fast float %f0, %f1
  %mul1 = fmul fast float %f2, %f3
  %mul2 = fmul fast float %mul0, %mul1
  ret float %mul2
}

Ie, instead of 3 dependent multiplies, we should have 2 independent fmuls
followed by the fmul of those results.

This can be generalized for N fmuls to form the optimal binary tree of
independent ops.

-- 
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/20141205/9c89035e/attachment.html>


More information about the llvm-bugs mailing list