[llvm-bugs] [Bug 25566] New: Possible Regression: std::max slower than std::fmax

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 18 11:47:01 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25566

            Bug ID: 25566
           Summary: Possible Regression: std::max slower than std::fmax
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pipping at exherbo.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 15310
  --> https://llvm.org/bugs/attachment.cgi?id=15310&action=edit
benchmark program

I wrote a toy program to compare the performance of std::max and std::fmax for
doubles.

I was surprised to find that even though it did not make a difference which one
I used (std::max wasn't slower than std::fmax) with clang 3.5 or all the
versions of gcc that I tested, it did make a difference with clang 3.7:
std::fmax was just as fast as with clang 3.5 but std::max was considerably
slower (by a factor of 5).

In particular, I considered the following compiler/os combinations:

On OS X 10.11.2 Beta:
(1) gcc 5.2.0
(2) clang-700.1.76 from XCode 7.1.1 (7B1005)
On Debian 8.2:
(3) gcc 4.9.2 (Debian 4.9.2-10)
(4) clang 3.5.0-10
(5) clang 3.7.0

If I use an abbreviation (i.e. normalisation) for the computational for the
std::fmax program on each machine (M for mac and L for linux), I arrive at
approximately the following table (with -O2):

c/l/s | std::fmax time | std::max time |
(1)   | 1M             | 1M            |
(2)   | 1M             | 5M            |
(3)   | 1L             | 1L            |
(4)   | 1L             | 1L            |
(5)   | 1L             | 5L            |

The two recent clang versions clang-700.1.76 on OS X and clang 3.7.0 on Linux
make the std::max version of my program slower by a factor of 5 than the
std::fmax version. This wouldn't surprise me if it wasn't for gcc and the older
version of clang (3.5 on Linux) which don't show this behaviour.

Since clang on OS X uses libc++ and my clang++ 3.7.0 installation on Linux uses
libstdc++, this issue does not seem to be related to the standard library.

I used the invocation

$ clang++ -DFUNC=fmax -O2 -std=c++11 max-vs-fmax-benchmark.cc && ./a.out 2
$ clang++ -DFUNC=max -O2 -std=c++11 max-vs-fmax-benchmark.cc && ./a.out 2

to obtain the aforementioned numbers.

-- 
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/20151118/799d98a5/attachment-0001.html>


More information about the llvm-bugs mailing list