<html>
<head>
<base href="http://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 --- - Missed scalar optimization"
href="http://llvm.org/bugs/show_bug.cgi?id=16405">16405</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed scalar optimization
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eugeni.stepanov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre># cat 1.cc
double *f(double *p, int n) {
for (int i = 0; i < n; ++i)
++p;
return p;
}
# clang++ -S -emit-llvm -O2 1.cc -o -
define double* @_Z1fPdi(double* %p, i32 %n) #0 {
entry:
%cmp2 = icmp sgt i32 %n, 0
br i1 %cmp2, label %for.body.lr.ph, label %for.end
for.body.lr.ph: ; preds = %entry
%0 = add i32 %n, -1
%1 = zext i32 %0 to i64
%2 = add i64 %1, 1
%scevgep = getelementptr double* %p, i64 %2
br label %for.end
for.end: ; preds = %for.body.lr.ph,
%entry
%p.addr.0.lcssa = phi double* [ %scevgep, %for.body.lr.ph ], [ %p, %entry ]
ret double* %p.addr.0.lcssa
}
Looks like in for.body.lr.ph BB %n > 0. This allows replacing the first 3
instructions with one zext (or sext). This would also result in simpler X86
asm, too. Current code compiles to:
testl %esi, %esi
jle .LBB0_2
# BB#1: # %for.body.lr.ph
decl %esi
leaq 8(%rdi,%rsi,8), %rdi
.LBB0_2: # %for.end
movq %rdi, %rax
ret</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>