[LLVMbugs] [Bug 21201] New: Missed optimization by O2? LTO generates faster code than O2 with all code visible

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 7 22:33:26 PDT 2014


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

            Bug ID: 21201
           Summary: Missed optimization by O2? LTO generates faster code
                    than O2 with all code visible
           Product: tools
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: vlovich at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13169
  --> http://llvm.org/bugs/attachment.cgi?id=13169&action=edit
Example project that benchmarks tagged

I know this sounds like expected behaviour, but is it possible there's some
optimization opportunity that clang is missing @ -02/-O3 whereas it's caught by
LTO?

The benchmark is I build a vector of a type that wraps a boost::variant of 2
types.  I then iterate invoking a function on each element of the vector & time
the result.

-O2 -flto: vector with types in random-order:
TaggedDispatch.TaggedDispatch (457.022675 ms)

-O2 -flto: vector with types in-order:
TaggedDispatch.TaggedDispatch (100.611670 ms)

-O2: vector with types in random order:
TaggedDispatch.TaggedDispatch (652.344259 ms)

-O2: vector in-order:
TaggedDispatch.TaggedDispatch (326.946609 ms)

-O3: vector with types in random order:
TaggedDispatch.TaggedDispatch (647.796656 ms)

-O3: vector in-order:
TaggedDispatch.TaggedDispatch (330.778245 ms)

We can see that somehow -flto manages to squeeze out quite a bit of performance
which is unexpected.  There's no difference between O2 & O3.

Numbers generated with Xcode's clang on OSX 10.10.  The version of boost
appeared to not matter (numbers consistent between boost 1.51 & boost 1.55).

You may have to edit the makefile to point to your boost if it's not in your
system path.

-- 
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/20141008/15fa9cef/attachment.html>


More information about the llvm-bugs mailing list