<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 --- - get_local and set_local elimination opportunities"
   href="https://llvm.org/bugs/show_bug.cgi?id=27357">27357</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>get_local and set_local elimination opportunities
          </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: 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>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Binaryen's simplify-locals pass removes get_locals that the backend doesn't,
and in some cases also a set_local or two. For example on fannkuch it removes
206 out of 3035 (7%) get_locals, and one set_local out of 1419.

STR: build a program then run binaryen shell --metrics --simplify-locals
--metrics and it will print out how many it removed.

He's an example text diff from fannkuch:

-              (set_local $$19
-                (i32.add
-                  (get_local $$15)
-                  (i32.const -1)
-                )
-              )
               (set_local $$14
                 (i32.add
                   (get_local $$14)
                   (i32.const -4)
                 )
               )
               (set_local $$13
                 (i32.const 1)
               )
               (set_local $$15
-                (get_local $$19)
+                (set_local $$19
+                  (i32.add
+                    (get_local $$15)
+                    (i32.const -1)
+                  )
+                )
               )

so it "sinks" that set_local down into the get_local, which is eliminated.

Talking to sunfish about this, he said he already knows what's going on here.</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>