<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 --- - using memory operand form of division would save on code size"
href="http://llvm.org/bugs/show_bug.cgi?id=17286">17286</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>using memory operand form of division would save on code size
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kkhoo@perfwizard.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>The following x86 codegen uses 2 vector load instructions (vmovupd) followed by
a reg-reg vector division instruction (vdivpd). It would be better to use the
memory operand form of the division instruction to save on code size; there are
4 extra bytes for the redundant load instruction.
In more complicated scenarios, it could also ease register pressure.
According to "iaca" (
<a href="http://software.intel.com/en-us/articles/intel-architecture-code-analyzer">http://software.intel.com/en-us/articles/intel-architecture-code-analyzer</a> ),
the code should perform identically. However, based on my testing on a Sandy
Bridge system, the smaller code also benchmarks slightly faster (4% faster for
the smaller code).
$ ./clang -v
clang version 3.4 (trunk 190938)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
$ cat div.c
void foo(double *restrict x, double *restrict y) {
int i;
for (i=0; i<2; i++) {
x[i] = x[i] / y[i];
}
}
$ ./clang -S -o - -O3 -fomit-frame-pointer -march=corei7-avx div.c
.section __TEXT,__text,regular,pure_instructions
.globl _foo
.align 4, 0x90
_foo: ## @foo
.cfi_startproc
## BB#0: ## %entry
vmovupd (%rsi), %xmm0
vmovupd (%rdi), %xmm1
vdivpd %xmm0, %xmm1, %xmm0
vmovupd %xmm0, (%rdi)
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>