[LLVMbugs] [Bug 16116] New: Reassociate should somtimes be redone after loop canonicalization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 22 15:08:08 PDT 2013


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

            Bug ID: 16116
           Summary: Reassociate should somtimes be redone after loop
                    canonicalization
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: jeroen.dobbelaere at synopsys.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The normal order of passes are:
- reassociate
- loop simplication/rotate
- licm (loop invariant code motion)

I found a speed regression between 3.1 and 3.2 (and later) because of
the following :

---
In the samples below I observer the following behavior:

Both start with the same expression:
  %add = add i32 %total.0, %next.0
  %add1 = add i32 %add, 1

-LLVM-3.1 converts this into:
--after Reassociate expressions:
  %add = add i32 %next.0, 1
  %add1 = add i32 %add, %total.0
-- after Canonicalize natural loops:
  %add = add i32 %next.0.ph, 1
  %add1 = add i32 %add, %total.0
-- and during 'loop invariant code motion':
LICM hoisting to while.cond.outer:   %add = add i32 %next.0.ph, 1

- LLVM-3.2 converts it into:  (Notice the reversion of %total.0 and %next.0)
--after Reassociate expressions:
  %add = add i32 %total.0, 1
  %add1 = add i32 %add, %next.0
-- after Canonicalize natural loops:
  %add = add i32 %total.0, 1
  %add1 = add i32 %add, %next.0.ph
-- and during 'loop invariant code motion':
-> %next.0.ph and '1' are loop invariant, but because those are spreaded, they
are not moved any more.

----

So:
- loop canonicalization introduces new opportunities for variables to be moved
outside the loop, but as reassociate expression is not redone, it depends on
'luck' (= order of the expression) if the opportunity is indeed seen.

-- 
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/20130522/fc6d6b6f/attachment.html>


More information about the llvm-bugs mailing list