<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - failed to hoist load through select-of-pointers?"
href="https://bugs.llvm.org/show_bug.cgi?id=34603">34603</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>failed to hoist load through select-of-pointers?
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</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></table>
<p>
<div>
<pre>Forking this off from <a class="bz_bug_link
bz_status_NEW "
title="NEW - Code pessimization when using typedef-aligned pointers"
href="show_bug.cgi?id=28343">bug 28343</a>:
double max_of_loads(double *x, double *y, int i) {
return x[i] > y[i] ? x[i] : y[i];
}
$ ./clang maxload.c -S -O2 -o - -emit-llvm
define double @max_of_loads(double* nocapture readonly %x, double* nocapture
readonly %y, i32 %i) {
entry:
%idxprom = sext i32 %i to i64
%arrayidx1 = getelementptr inbounds double, double* %x, i64 %idxprom
%0 = load double, double* %arrayidx1, align 8, !tbaa !3
%arrayidx2 = getelementptr inbounds double, double* %y, i64 %idxprom
%1 = load double, double* %arrayidx2, align 8, !tbaa !3
%cmp = fcmp ogt double %0, %1
%.sink = select i1 %cmp, double* %x, double* %y
%arrayidx6 = getelementptr inbounds double, double* %.sink, i64 %idxprom
%2 = load double, double* %arrayidx6, align 8, !tbaa !3
ret double %2
}
------------------------------------------------------------------------
I don't think there's any alias-based restrictions impeding this transform?
define double @max_of_loads(double* nocapture readonly %x, double* nocapture
readonly %y, i32 %i) {
entry:
%idxprom = sext i32 %i to i64
%arrayidx = getelementptr inbounds double, double* %x, i64 %idxprom
%arrayidx2 = getelementptr inbounds double, double* %y, i64 %idxprom
%0 = load double, double* %arrayidx, align 8, !tbaa !3
%1 = load double, double* %arrayidx2, align 8, !tbaa !3
%cmp = fcmp ogt double %0, %1
%sel = select i1 %cmp, double %0, double %1
ret double %sel
}</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>