<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 --- - [x86] Unnecessary materialization of call argument"
href="https://llvm.org/bugs/show_bug.cgi?id=26330">26330</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[x86] Unnecessary materialization of call argument
</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>Linux
</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>hans@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Blocks</th>
<td>26299
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>When pushing arguments to a function call, constant arguments can go as
immediates in the push instructions:
void f(int, int);
void g() {
f(0, 5);
}
00000000 <?g@@YAXXZ>:
0: 6a 05 push $0x5
2: 6a 00 push $0x0
4: e8 00 00 00 00 call 9 <?g@@YAXXZ+0x9>
9: 83 c4 08 add $0x8,%esp
c: c3 ret
But it seems that if the same value is used more than once, we materialize it
in a register:
void g() {
f(5, 5);
}
00000000 <?g@@YAXXZ>:
0: b8 05 00 00 00 mov $0x5,%eax
5: 50 push %eax
6: 50 push %eax
7: e8 00 00 00 00 call c <?g@@YAXXZ+0xc>
c: 83 c4 08 add $0x8,%esp
f: c3
The savings on smaller push instructions is offset by the mov instruction.</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>