<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 --- - hoisting expensive ops like FP division is bad for perf"
href="https://llvm.org/bugs/show_bug.cgi?id=24818">24818</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>hoisting expensive ops like FP division is bad for perf
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Transformation Utilities
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Test case based on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - clang++ -O1 evaluates wrong branch in C++ ternary operator ?:"
href="show_bug.cgi?id=24807">bug 24807</a>:
double foo(double a, double b) {
return (a > 0.0) ? b/a : 0.0;
}
If 'a' is always less than zero, then we should never clog up an FPU with a
potentially very expensive, non-pipelined division instruction. But we're
hoisting that op with 'opt' built from r247615:
target triple = "x86_64-apple-macosx10.10.0"
define double @foo(double %a, double %b) #0 {
entry:
%cmp = fcmp ogt double %a, 0.000000e+00
%div = fdiv double %b, %a
%cond = select i1 %cmp, double %div, double 0.000000e+00
ret double %cond
}
This is a relatively recent change; it doesn't happen with the clang shipped
with Xcode based on 3.6.0:
define double @foo(double %a, double %b) #0 {
%1 = fcmp ogt double %a, 0.000000e+00
br i1 %1, label %2, label %4
; <label>:2 ; preds = %0
%3 = fdiv double %b, %a
br label %4
; <label>:4 ; preds = %0, %2
%5 = phi double [ %3, %2 ], [ 0.000000e+00, %0 ]
ret double %5
}</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>