<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Possible Regression: std::max slower than std::fmax"
href="https://llvm.org/bugs/show_bug.cgi?id=25566">25566</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Possible Regression: std::max slower than std::fmax
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pipping@exherbo.org
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=15310" name="attach_15310" title="benchmark program">attachment 15310</a> <a href="attachment.cgi?id=15310&action=edit" title="benchmark program">[details]</a></span>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>