<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 - Duplicate constants in stack lowering"
href="https://bugs.llvm.org/show_bug.cgi?id=37299">37299</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Duplicate constants in stack lowering
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>alonzakai@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The Souper superoptimizer finds stuff like this in the wasm backend's output,
; start LHS (in $luaL_error)
%0:i32 = var
; (i32.sub(get_local $5)(i32.const 128))
%1 = sub %0, 128:i32
; (i32.add(get_local $3)(i32.const 128))
%2 = add %1, 128:i32
infer %2
which corresponds to wasm like this
(func $luaL_error (; 41 ;) (type $3) (param $var$0 i32) (param $var$1 i32)
(param $var$2 i32) (result i32)
(local $var$3 i32)
(local $var$4 i32)
(i32.store
(i32.const 1024)
(tee_local $var$3
(i32.sub
(i32.load
(i32.const 1024)
)
(i32.const 128)
)
)
)
[..]
(i32.store
(i32.const 1024)
(i32.add
(get_local $var$3)
(i32.const 128)
)
)
(get_local $var$0)
)
So it subs 128 from the stack pointer, then adds 128 to restore it. An
alternative would be to use a local to save the original value instead, which
would save a few bytes (avoid the add + constant at the end), although I'm not
sure how that would affect the size of the uses of the stack pointer in the
middle there.</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>